Skip to content

Instantly share code, notes, and snippets.

@Yannick243
Created March 31, 2021 14:53
Show Gist options
  • Save Yannick243/bbc2767f250ae98c031caf39a25fb1df to your computer and use it in GitHub Desktop.
Save Yannick243/bbc2767f250ae98c031caf39a25fb1df to your computer and use it in GitHub Desktop.
export const b64toBlob = (dataURI) => {
const byteString = atob(dataURI.split(',')[1])
const ab = new ArrayBuffer(byteString.length)
const ia = new Uint8Array(ab)
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i)
}
return new Blob([ab], { type: 'image/jpeg' })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment