Skip to content

Commit e798577

Browse files
authored
Update flow.js
1 parent 6aca5b2 commit e798577

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/flow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
*/
8080
this.defaults = {
8181
chunkSize: 1024 * 1024,
82+
calculateChunkSize: null,
8283
forceChunkSize: false,
8384
simultaneousUploads: 3,
8485
singleFile: false,
@@ -938,8 +939,13 @@
938939
// Rebuild stack of chunks from file
939940
this._prevProgress = 0;
940941
var round = this.flowObj.opts.forceChunkSize ? Math.ceil : Math.floor;
942+
var calculateChunkSize = this.flowObj.opts.calculateChunkSize;
943+
var chunkSize = this.flowObj.opts.chunkSize;
944+
if (typeof calculateChunkSize === 'function') {
945+
chunkSize = calculateChunkSize(this);
946+
}
941947
var chunks = Math.max(
942-
round(this.size / this.flowObj.opts.chunkSize), 1
948+
round(this.size / chunkSize), 1
943949
);
944950
for (var offset = 0; offset < chunks; offset++) {
945951
this.chunks.push(

0 commit comments

Comments
 (0)