I am trying to convert a blob to an array. The blob has a .size that is not zero and after the assignment of this.result which should give the converted array is zero length. Can anybody help?
function createArrayFromBlob(blob){
return new Promise(function(resolve, reject) {
var arrayBuffer;
var fileReader = new FileReader();
fileReader.onload = function() {
console.log("3: " + blob.size);
arrayBuffer = this.result;
console.log("4: " + arrayBuffer.length);
resolve(arrayBuffer);
};
fileReader.onerror = function(e) {
console.log(e);
};
fileReader.readAsArrayBuffer(blob);
});
}
Output:
3: 4196020
4: undefined
Aucun commentaire:
Enregistrer un commentaire