I have blob url , i need to get it converted into a byte [] for storing purpose . I initially tried converting it to a base64 using FileReader
var xhr = new XMLHttpRequest;
xhr.responseType = 'blob';
xhr.onload = function() {
var recoveredBlob = xhr.response;
var reader = new FileReader;
reader.onload = function() {
var blobAsDataUrl = reader.result;
return blobAsDataUrl.toString().replace('data:image/png;base64,', '');
};
reader.readAsDataURL(recoveredBlob);
};
xhr.open('GET', blobUrl);
xhr.send();
Then used following to convert it to an array
var bData = atob(blob);
console.log('------ bData : ', bData);
const array = Uint8Array.from(bData, b => b.charCodeAt(0));
But I do not get the intended binary output ..