From 7494999bce7afa895d2ca16ff020ae1ceb73e973 Mon Sep 17 00:00:00 2001 From: abir Date: Wed, 26 Jul 2023 18:12:59 +0400 Subject: [PATCH] fix: download response --- .../web/src/Transport/Response/DownloadResponse.ts | 5 ++--- yarn.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/web/src/Transport/Response/DownloadResponse.ts b/packages/web/src/Transport/Response/DownloadResponse.ts index dcfa7248..aeeaca43 100644 --- a/packages/web/src/Transport/Response/DownloadResponse.ts +++ b/packages/web/src/Transport/Response/DownloadResponse.ts @@ -35,7 +35,7 @@ export class DownloadResponse extends ResponseAbstract { function createHeaders(options: DownloadOptions): Record { const size = options.size; const headers: Record = { - "Content-Disposition": `attachment; filename=${options.filename}`, + "Content-Disposition": `attachment; filename=${encodeURI(options.filename)}`, "Content-Length": size.toString(), "Content-Type": options.mimeType, }; @@ -66,10 +66,9 @@ function createTemporarySource(options: DownloadOptionsAuth): ResponseArgs(); writable.once("close", () => stat(tmpname).then((s) => defer.resolve(s.size))); + inputReadable.pipe(writable); const ready = (): Readable => createReadStream(tmpname).once("close", () => unlink(tmpname)); const headers = (size: number): Record => createHeaders({...options, size}); diff --git a/yarn.lock b/yarn.lock index 4e89b2fd..87100728 100644 --- a/yarn.lock +++ b/yarn.lock @@ -417,7 +417,7 @@ __metadata: languageName: node linkType: hard -"@bunt/app@^0.29.6, @bunt/app@workspace:packages/app": +"@bunt/app@^0.29.9, @bunt/app@workspace:packages/app": version: 0.0.0-use.local resolution: "@bunt/app@workspace:packages/app" dependencies: @@ -457,7 +457,7 @@ __metadata: version: 0.0.0-use.local resolution: "@bunt/cli@workspace:packages/cli" dependencies: - "@bunt/app": ^0.29.6 + "@bunt/app": ^0.29.9 "@bunt/assert": ^0.29.0 "@bunt/util": ^0.29.0 path-to-regexp: ^6.2.1 @@ -552,11 +552,11 @@ __metadata: languageName: unknown linkType: soft -"@bunt/web@^0.29.7, @bunt/web@workspace:packages/web": +"@bunt/web@^0.29.9, @bunt/web@workspace:packages/web": version: 0.0.0-use.local resolution: "@bunt/web@workspace:packages/web" dependencies: - "@bunt/app": ^0.29.6 + "@bunt/app": ^0.29.9 "@bunt/assert": ^0.29.0 "@bunt/async": ^0.29.6 "@bunt/is": ^0.29.0 @@ -571,14 +571,14 @@ __metadata: version: 0.0.0-use.local resolution: "@bunt/ws@workspace:packages/ws" dependencies: - "@bunt/app": ^0.29.6 + "@bunt/app": ^0.29.9 "@bunt/assert": ^0.29.0 "@bunt/async": ^0.29.6 "@bunt/is": ^0.29.0 "@bunt/type": ^0.29.0 "@bunt/unit": ^0.29.6 "@bunt/util": ^0.29.0 - "@bunt/web": ^0.29.7 + "@bunt/web": ^0.29.9 "@types/websocket": ^1.0.5 "@types/ws": ^8.5.5 websocket: ^1.0.34