Skip to content

Commit

Permalink
Added comment to explain the usage of more supported arrayBuffer() me…
Browse files Browse the repository at this point in the history
…thod instead of FileReader.
  • Loading branch information
mbuella committed Jan 10, 2025
1 parent 61393ef commit 34129e7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/php-wasm/universal/src/lib/encode-as-multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ export async function encodeAsMultipart(
}

function fileToUint8Array(file: File): Promise<Uint8Array> {
/**
* @mbuella: Use File.arrayBuffer() to get a Uint8Array from a file, avoiding FileReader
* which is browser-specific. This method is supported in major browsers and NodeJS/Deno runtimes.
*/
return file.arrayBuffer().then((fileBuffer) => new Uint8Array(fileBuffer));
}

0 comments on commit 34129e7

Please sign in to comment.