Skip to content

Instantly share code, notes, and snippets.

@ijse
Created June 4, 2015 07:04
Show Gist options
  • Save ijse/9362b096c4242fac85ac to your computer and use it in GitHub Desktop.
Save ijse/9362b096c4242fac85ac to your computer and use it in GitHub Desktop.
convert dataUrl to blog
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment