Skip to content

Instantly share code, notes, and snippets.

@krisai
Forked from tgcnzn/Convert Base64 to Blob
Created September 23, 2020 01:46
Show Gist options
  • Save krisai/307c6e07da710625b9d81ff5f404b620 to your computer and use it in GitHub Desktop.
Save krisai/307c6e07da710625b9d81ff5f404b620 to your computer and use it in GitHub Desktop.
function base64ToBlob(data) {
var byteString = atob(data.split(',')[1]);
var mimeString = data.split(',')[0].split(':')[1].split(';')[0]
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
var blob = new Blob([ab]);
return blob;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment