Skip to content

Commit ac8c972

Browse files
committed
0.2.0 - fix file size issue
Fix: When using `Downloader`, the file size is not configured in the stream saver. Now, it has been fixed.
1 parent 4ff3366 commit ac8c972

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
3. Add the cross-origin support when serving the data to clients (e.g. the browser).
1414
4. Add the external URL proxy support for fetching the cross-origin resources.
1515

16+
#### :wrench: Fix
17+
18+
1. Fix: When using `Downloader`, the file size is not configured in the stream saver. Now, it has been fixed.
19+
1620
#### :floppy_disk: Change
1721

1822
1. Drop the legacy `components.downloader` module because it has been replaced by `components.PlainDownloader` now.

src/lib/fragments/Downloader.react.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ const downloadFile = (
6565
window.WritableStream = streamSaver.WritableStream;
6666
}
6767

68-
const fileStream = streamSaver.createWriteStream(fileName);
68+
const fileSize = resp.headers.get("Content-Length");
69+
const fileStream = streamSaver.createWriteStream(fileName, {
70+
size: fileSize ? parseInt(fileSize) || undefined : undefined,
71+
});
6972
const readableStream = resp.body;
7073
if (!readableStream) {
7174
try {

0 commit comments

Comments
 (0)