Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Created August 2, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthieu-D/4ae83e3bea0d1077d7f53e087b0c5a91 to your computer and use it in GitHub Desktop.
Save matthieu-D/4ae83e3bea0d1077d7f53e087b0c5a91 to your computer and use it in GitHub Desktop.
dataURItoBlob(dataURI) {
// code adapted from: http://stackoverflow.com/questions/33486352/cant-upload-image-to-aws-s3-from-ionic-camera
let binary = atob(dataURI.split(',')[1]);
let array = [];
for (let i = 0; i < binary.length; 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