-
-
Save alekssamos/23fc6e4c645f82380ed1fcdd252c144a to your computer and use it in GitHub Desktop.
Convert array buffer to base64 string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment