Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert array buffer to base64 string
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
@arturzhitkovcih

This comment has been minimized.

Copy link

@arturzhitkovcih arturzhitkovcih commented Mar 27, 2020

     let base64String = btoa(String.fromCharCode(...file));
@Lekha30

This comment has been minimized.

Copy link

@Lekha30 Lekha30 commented Sep 29, 2021

btoa() is deprecated

@caebwallace

This comment has been minimized.

Copy link

@caebwallace caebwallace commented Sep 29, 2021

btoa() is deprecated

Can you give your source please ?
https://developer.mozilla.org/en-US/docs/Web/API/btoa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment