Created
June 3, 2016 14:02
-
-
Save Kashkovsky/093fc4174cf52fccf81477a9bbf5ecd1 to your computer and use it in GitHub Desktop.
Convert data Uri to blob
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
function dataUrItoBlob(dataUri) { | |
var binary = atob(dataUri.split(',')[1]); | |
var mimeString = dataUri.split(',')[0].split(':')[1].split(';')[0]; | |
var array = []; | |
for (var i = 0; i < binary.length; i++) { | |
array.push(binary.charCodeAt(i)); | |
} | |
return new Blob([new Uint8Array(array)], { type: mimeString }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment