Skip to content

Commit

Permalink
increase default chunkSize to 30 MB
Browse files Browse the repository at this point in the history
This drastically improves performance on faster connections, at the cost
of potentially needing to retry a larger chunk of data when a connection
is interrupted.

It's impossible to serve both fast and slow/unreliable internet
connections well with a single fixed setting here, so in the future this
should be made to scale dynamically to 1) maximize upload speed on fast
connections, and 2) constrain the amount of time that will be wasted
re-uploading a partial segment if it is interrupted.
  • Loading branch information
bgentry authored and jsanford8 committed Mar 3, 2022
1 parent 35b272f commit 7f2658e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ picker.onchange = () => {
const upload = UpChunk.createUpload({
endpoint: getUploadUrl,
file: picker.files[0],
chunkSize: 5120, // Uploads the file in ~5mb chunks
chunkSize: 30720, // Uploads the file in ~30 MB chunks
});

// subscribe to events
Expand Down Expand Up @@ -109,7 +109,7 @@ function Page() {
const upload = UpChunk.createUpload({
endpoint: url, // Authenticated url
file: inputRef.files[0], // File object with your video file’s properties
chunkSize: 5120, // Uploads the file in ~5mb chunks
chunkSize: 30720, // Uploads the file in ~30 MB chunks
});

// Subscribe to events
Expand Down Expand Up @@ -168,7 +168,7 @@ Returns an instance of `UpChunk` and begins uploading the specified `File`.

An object with any headers you'd like included with the `PUT` request for each chunk.

- `chunkSize` <small>type: `integer`, default:`5120`</small>
- `chunkSize` <small>type: `integer`, default:`30720`</small>

The size in kb of the chunks to split the file into, with the exception of the final chunk which may be smaller. This parameter should be in multiples of 256.

Expand Down
2 changes: 1 addition & 1 deletion example/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ picker.onchange = () => {
const upload = UpChunk.createUpload({
endpoint,
file,
chunkSize: 5120,
chunkSize: 30720,
});

// subscribe to events
Expand Down
2 changes: 1 addition & 1 deletion src/upchunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class UpChunk {
this.file = options.file;
this.headers = options.headers || ({} as XhrHeaders);
this.method = options.method || 'PUT';
this.chunkSize = options.chunkSize || 5120;
this.chunkSize = options.chunkSize || 30720;
this.attempts = options.attempts || 5;
this.delayBeforeAttempt = options.delayBeforeAttempt || 1;

Expand Down

0 comments on commit 7f2658e

Please sign in to comment.