From c4db22f6262dba047370798f75c681ea11f011a7 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 22 May 2025 22:32:52 +0200 Subject: [PATCH] [bug] Actually pass the file object to wasm as bytes --- src/pages/account/key-value-section.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/account/key-value-section.ts b/src/pages/account/key-value-section.ts index 081a228..66f8b21 100644 --- a/src/pages/account/key-value-section.ts +++ b/src/pages/account/key-value-section.ts @@ -36,7 +36,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection = keyInput: HTMLInputElement, valueInput: HTMLInputElement, fileInput: HTMLInputElement, - fileBlob: File | null + fileBlob: number[] | null }[] = []; const inputStyle = 'flex: 1; height: 2.5rem; padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.375rem;'; @@ -92,7 +92,8 @@ export function createKeyValueSection(title: string, id: string, isRoleSection = fileInput.onchange = async () => { const file = fileInput.files?.[0]; if (!file) return; - rowState.fileBlob = file; + const buffer = await file.arrayBuffer(); + rowState.fileBlob = Array.from(new Uint8Array(buffer)); valueInput.value = `📄 ${file.name}`; valueInput.disabled = true; @@ -174,7 +175,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection = const key = row.keyInput.value.trim(); if (!key) continue; if (row.fileBlob) { - data[key] = row.fileBlob; // return the File as Blob + data[key] = row.fileBlob; } else { data[key] = row.valueInput.value.trim(); }