From 55b6e9ea51435be533de91a9cdaf21b098682455 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Thu, 27 Apr 2023 19:01:26 +0200 Subject: [PATCH] don't use blob --- .../frontend/src/lib/ui/FileUpload.svelte | 7 +- packages/frontend/src/lib/ui/ShowNote.svelte | 2 +- packages/frontend/src/lib/utils.ts | 2 +- packages/frontend/tsconfig.json | 3 +- packages/shared/src/adapters.ts | 11 +- packages/shared/src/api.ts | 4 +- packages/shared/tsconfig.json | 107 ++---------------- pnpm-lock.yaml | 3 + 8 files changed, 27 insertions(+), 112 deletions(-) diff --git a/packages/frontend/src/lib/ui/FileUpload.svelte b/packages/frontend/src/lib/ui/FileUpload.svelte index ea7db4d..afddf86 100644 --- a/packages/frontend/src/lib/ui/FileUpload.svelte +++ b/packages/frontend/src/lib/ui/FileUpload.svelte @@ -8,19 +8,20 @@ export let label: string = '' export let files: FileDTO[] = [] - function fileToDTO(file: File): FileDTO { + async function fileToDTO(file: File): Promise { return { name: file.name, size: file.size, type: file.type, - contents: file, + contents: new Uint8Array(await file.arrayBuffer()), } } async function onInput(e: Event) { const input = e.target as HTMLInputElement if (input?.files?.length) { - files = [...files, ...Array.from(input.files).map(fileToDTO)] + const toAdd = await Promise.all(Array.from(input.files).map(fileToDTO)) + files = [...files, ...toAdd] } } diff --git a/packages/frontend/src/lib/ui/ShowNote.svelte b/packages/frontend/src/lib/ui/ShowNote.svelte index f5fda15..5065c8f 100644 --- a/packages/frontend/src/lib/ui/ShowNote.svelte +++ b/packages/frontend/src/lib/ui/ShowNote.svelte @@ -3,7 +3,7 @@