diff --git a/api/lib/api/files.ts b/api/lib/api/files.ts index a561e6ab5..f7c1f9bb5 100644 --- a/api/lib/api/files.ts +++ b/api/lib/api/files.ts @@ -9,7 +9,7 @@ export default class { this.api = api; } - async download(hash: string) { + async download(hash: string): Promise { const url = new URL(`/Marti/sync/content`, this.api.url); url.searchParams.append('hash', hash); @@ -17,7 +17,7 @@ export default class { method: 'GET' }, true); - return res.body.getReader(); + return res.body; } async delete(hash: string) { diff --git a/api/routes/marti-files.ts b/api/routes/marti-files.ts index 3c6418a2b..1c6136a7f 100644 --- a/api/routes/marti-files.ts +++ b/api/routes/marti-files.ts @@ -59,13 +59,7 @@ export default async function router(schema: Schema, config: Config) { const file = await api.Files.download(req.params.hash); - let { done, value } = await file.read(); - while (!done) { - res.write(value); - ({ done, value } = await file.read()); - } - - res.end() + file.pipe(res); } catch (err) { return Err.respond(err, res); }