From 61393efb52548035ef7f126d490777c977c2d7c0 Mon Sep 17 00:00:00 2001 From: "Marlon B. Buella" Date: Mon, 6 Jan 2025 15:04:03 +0000 Subject: [PATCH] Rewrote fileToUint8Array function to be also NodeJS/Deno compatible. --- .../php-wasm/universal/src/lib/encode-as-multipart.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/php-wasm/universal/src/lib/encode-as-multipart.ts b/packages/php-wasm/universal/src/lib/encode-as-multipart.ts index 120fbf8c22..4fa4c6a6fa 100644 --- a/packages/php-wasm/universal/src/lib/encode-as-multipart.ts +++ b/packages/php-wasm/universal/src/lib/encode-as-multipart.ts @@ -47,11 +47,5 @@ export async function encodeAsMultipart( } function fileToUint8Array(file: File): Promise { - return new Promise((resolve) => { - const reader = new FileReader(); - reader.onload = () => { - resolve(new Uint8Array(reader.result as ArrayBuffer)); - }; - reader.readAsArrayBuffer(file); - }); + return file.arrayBuffer().then((fileBuffer) => new Uint8Array(fileBuffer)); }