From fa561df14f332b97ea65c0ab8ec8a6bcb7410553 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 18 Mar 2024 08:18:30 +0500 Subject: [PATCH] web: allow reading data from stream when writing zip --- apps/web/src/utils/streams/zip-stream.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/src/utils/streams/zip-stream.ts b/apps/web/src/utils/streams/zip-stream.ts index 54809cf5b..46a44b1da 100644 --- a/apps/web/src/utils/streams/zip-stream.ts +++ b/apps/web/src/utils/streams/zip-stream.ts @@ -29,7 +29,7 @@ configure({ Deflate, Inflate }); export type ZipFile = { path: string; - data: string | Uint8Array; + data: string | Uint8Array | ReadableStream; mtime?: Date; ctime?: Date; }; @@ -52,7 +52,9 @@ export function createZipStream(signal?: AbortSignal) { chunk.path, typeof chunk.data === "string" ? new TextReader(chunk.data) - : new Uint8ArrayReader(chunk.data), + : chunk.data instanceof Uint8Array + ? new Uint8ArrayReader(chunk.data) + : chunk.data, { creationDate: chunk.ctime, lastModDate: chunk.mtime