Skip to content

Commit

Permalink
fix arraybuffer types
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Dec 20, 2024
1 parent 93313be commit 97bf064
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function resolveSerializableFile(
): Promise<[contentType: string | undefined, ArrayBuffer]> {
if (file.dataUrl.startsWith("https:")) {
const response = await fetch(file.dataUrl);
const buffer = Buffer.from(await response.arrayBuffer());
const buffer = await response.arrayBuffer();
return [response.headers.get("Content-Type") ?? file.type, buffer];
} else if (file.dataUrl.startsWith("http:")) {
throw new Error("HTTP is not supported: " + file.dataUrl);
Expand All @@ -16,7 +16,7 @@ export async function resolveSerializableFile(
if (header == null || base64String == null) {
throw new Error("Invalid data URL: " + file.dataUrl);
}
const bstr = Buffer.from(base64String, "base64");
const bstr = Uint8Array.from(Buffer.from(base64String, "base64")).buffer;
return [file.type, bstr];
} else {
throw new Error("Invalid data URL: " + file.dataUrl);
Expand Down

0 comments on commit 97bf064

Please sign in to comment.