mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
avoid using for await
This commit is contained in:
parent
aa3aecb074
commit
9389039c7a
12
src/s3.ts
12
src/s3.ts
@ -225,12 +225,12 @@ const getObjectBodyToArrayBuffer = async (
|
||||
b: Readable | ReadableStream | Blob
|
||||
) => {
|
||||
if (b instanceof Readable) {
|
||||
const chunks: Uint8Array[] = [];
|
||||
for await (let chunk of b) {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
const buf = Buffer.concat(chunks);
|
||||
return bufferToArrayBuffer(buf);
|
||||
return (await new Promise((resolve, reject) => {
|
||||
const chunks: Uint8Array[] = [];
|
||||
b.on("data", (chunk) => chunks.push(chunk));
|
||||
b.on("error", reject);
|
||||
b.on("end", () => resolve(bufferToArrayBuffer(Buffer.concat(chunks))));
|
||||
})) as ArrayBuffer;
|
||||
} else if (b instanceof ReadableStream) {
|
||||
return await new Response(b, {}).arrayBuffer();
|
||||
} else if (b instanceof Blob) {
|
||||
|
Loading…
Reference in New Issue
Block a user