Skip to content

Commit

Permalink
feat(upload): Add possibility to upload big files
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Romański authored and Piotr Romański committed Jan 13, 2022
1 parent aca1768 commit e33a91d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/api/upload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export interface ProgressEvent {
}

const DEFAULT_PROGRESS_INTERVAL = 1000;

const BIG_FILE_THRESHOLD = 50 * 1000 * 1000 * 1000 // 50GB
const BIG_FILE_PART_SIZE = 10 * 1024 * 1024; // 10MB
const normalizeProgress = (current, last) => {
current.totalBytes = Math.max(current.totalBytes, last.totalBytes);
current.totalPercent = Math.max(current.totalPercent, last.totalPercent);
Expand Down Expand Up @@ -206,6 +207,9 @@ export class Upload extends EventEmitter {

const f = await getFile(input, this.sanitizerOptions);
f.customName = this.overrideFileName;
if (f.size > BIG_FILE_THRESHOLD){
this.uploader.setPartSize(BIG_FILE_THRESHOLD);
}
this.uploader.addFile(f);

this.startProgressInterval();
Expand Down

0 comments on commit e33a91d

Please sign in to comment.