Skip to content

Instantly share code, notes, and snippets.

@alextanhongpin
Created March 17, 2017 11:15
Show Gist options
  • Save alextanhongpin/e474981ca046f1f87f33cda6f3562fb0 to your computer and use it in GitHub Desktop.
Save alextanhongpin/e474981ca046f1f87f33cda6f3562fb0 to your computer and use it in GitHub Desktop.
converts base 64 url to image
export default function dataURItoBlob (base64) {
const byteString = window.atob(base64)
const mimestring = 'image/jpeg'
const content = []
for (let i = 0; i < byteString.length; i++) {
content[i] = byteString.charCodeAt(i)
}
return new window.Blob([new Uint8Array(content)], {type: mimestring})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment