Changed blob to buffer fallback
This commit is contained in:
parent
e73f64a3b5
commit
dd13208424
@ -3,8 +3,21 @@ async function blobToBuffer(blob) {
|
||||
const arrayBuffer = await blob.arrayBuffer();
|
||||
return new Uint8Array(arrayBuffer);
|
||||
} else {
|
||||
const arrayBuffer = new Response(blob).arrayBuffer();
|
||||
return new Uint8Array(arrayBuffer);
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
function onLoadEnd(event) {
|
||||
reader.removeEventListener("loadend", onLoadEnd, false);
|
||||
if (event.error) {
|
||||
reject(event.error);
|
||||
} else {
|
||||
resolve(Buffer.from(reader.result));
|
||||
}
|
||||
}
|
||||
|
||||
reader.addEventListener("loadend", onLoadEnd, false);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user