#Covert Data URI to Blob
-
-
Save apendua/5a121585a9d4e4c84e14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert Data URI to Blob | |
*/ | |
function dataURItoBlob(dataURI) { | |
var binary = atob(dataURI.split(',')[1]); | |
var array = []; | |
var i = 0; | |
var l = binary.length; | |
for ( ; i < l; i++) { | |
array.push(binary.charCodeAt(i)); | |
} | |
return new Blob([new Uint8Array(array)], {type: 'image/jpeg'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment