6

I am trying to parse blob object into base64 string in javascript. Please help. my code is

var reader = new FileReader();

reader.addEventListener("loadend", function () {
    // reader.result contains the contents of blob as a typed array
    var buffer = reader.result;
    var view = new Uint8Array(buffer);
    var binary = String.fromCharCode.apply(window, view);
    var base64 = btoa(binary);
    cb(base64);
    console.log(base64);
}); 

reader.readAsArrayBuffer(data.blob);
3
  • 1
    So what is the error you are facing? Commented Jun 19, 2017 at 11:38
  • 1
    Uncaught RangeError: Maximum call stack size exceeded Commented Jun 19, 2017 at 11:42
  • Does this answer your question? Convert blob to base64 Commented Feb 1, 2022 at 22:11

1 Answer 1

6

You may try this-

var blob = //your blob data;

var reader = new FileReader();

reader.readAsDataURL(blob); 
reader.onloadend = function() {
    var base64data = reader.result;                
    console.log(base64data);
    return;
}

Refer- Convert blob to base64

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.