Skip to content

Commit e33a91d

Browse files
Piotr RomańskiPiotr Romański
authored andcommitted
feat(upload): Add possibility to upload big files
1 parent aca1768 commit e33a91d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/api/upload/upload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export interface ProgressEvent {
3434
}
3535

3636
const DEFAULT_PROGRESS_INTERVAL = 1000;
37-
37+
const BIG_FILE_THRESHOLD = 50 * 1000 * 1000 * 1000 // 50GB
38+
const BIG_FILE_PART_SIZE = 10 * 1024 * 1024; // 10MB
3839
const normalizeProgress = (current, last) => {
3940
current.totalBytes = Math.max(current.totalBytes, last.totalBytes);
4041
current.totalPercent = Math.max(current.totalPercent, last.totalPercent);
@@ -206,6 +207,9 @@ export class Upload extends EventEmitter {
206207

207208
const f = await getFile(input, this.sanitizerOptions);
208209
f.customName = this.overrideFileName;
210+
if (f.size > BIG_FILE_THRESHOLD){
211+
this.uploader.setPartSize(BIG_FILE_THRESHOLD);
212+
}
209213
this.uploader.addFile(f);
210214

211215
this.startProgressInterval();

0 commit comments

Comments
 (0)