Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2016 06:12
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
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);
Copy link

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

Copy link

Lekha30 commented Sep 29, 2021

btoa() is deprecated

Copy link

btoa() is deprecated

Can you give your source please ?

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