Skip to content

Commit

Permalink
Mission Content Download
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Mar 6, 2024
1 parent 121c641 commit 42d98a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions api/lib/api/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export default class {
this.api = api;
}

async download(hash: string) {
async download(hash: string): Promise<Readable> {
const url = new URL(`/Marti/sync/content`, this.api.url);
url.searchParams.append('hash', hash);

const res = await this.api.fetch(url, {
method: 'GET'
}, true);

return res.body.getReader();
return res.body;
}

async delete(hash: string) {
Expand Down
8 changes: 1 addition & 7 deletions api/routes/marti-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 42d98a5

Please sign in to comment.