Skip to content

Commit 45dcba1

Browse files
committed
Release v2.14.0
1 parent d951c40 commit 45dcba1

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

dist/flow.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Flow.js is a library providing multiple simultaneous, stable and
1313
* resumable uploads via the HTML5 File API.
1414
* @param [opts]
15-
* @param {number} [opts.chunkSize]
15+
* @param {number|Function} [opts.chunkSize]
1616
* @param {bool} [opts.forceChunkSize]
1717
* @param {number} [opts.simultaneousUploads]
1818
* @param {bool} [opts.singleFile]
@@ -89,6 +89,7 @@
8989
headers: {},
9090
withCredentials: false,
9191
preprocess: null,
92+
changeRawDataBeforeSend: null,
9293
method: 'multipart',
9394
testMethod: 'GET',
9495
uploadMethod: 'POST',
@@ -749,6 +750,12 @@
749750
* @type {string}
750751
*/
751752
this.uniqueIdentifier = (uniqueIdentifier === undefined ? flowObj.generateUniqueIdentifier(file) : uniqueIdentifier);
753+
754+
/**
755+
* Size of Each Chunk
756+
* @type {number}
757+
*/
758+
this.chunkSize = 0;
752759

753760
/**
754761
* List of chunks
@@ -937,8 +944,9 @@
937944
// Rebuild stack of chunks from file
938945
this._prevProgress = 0;
939946
var round = this.flowObj.opts.forceChunkSize ? Math.ceil : Math.floor;
947+
this.chunkSize = evalOpts(this.flowObj.opts.chunkSize, this);
940948
var chunks = Math.max(
941-
round(this.size / this.flowObj.opts.chunkSize), 1
949+
round(this.size / this.chunkSize), 1
942950
);
943951
for (var offset = 0; offset < chunks; offset++) {
944952
this.chunks.push(
@@ -1152,7 +1160,7 @@
11521160
* Size of a chunk
11531161
* @type {number}
11541162
*/
1155-
this.chunkSize = this.flowObj.opts.chunkSize;
1163+
this.chunkSize = this.fileObj.chunkSize;
11561164

11571165
/**
11581166
* Chunk start byte in a file
@@ -1266,7 +1274,7 @@
12661274
getParams: function () {
12671275
return {
12681276
flowChunkNumber: this.offset + 1,
1269-
flowChunkSize: this.flowObj.opts.chunkSize,
1277+
flowChunkSize: this.chunkSize,
12701278
flowCurrentChunkSize: this.endByte - this.startByte,
12711279
flowTotalSize: this.fileObj.size,
12721280
flowIdentifier: this.fileObj.uniqueIdentifier,
@@ -1376,6 +1384,10 @@
13761384

13771385
var uploadMethod = evalOpts(this.flowObj.opts.uploadMethod, this.fileObj, this);
13781386
var data = this.prepareXhrRequest(uploadMethod, false, this.flowObj.opts.method, this.bytes);
1387+
var changeRawDataBeforeSend = this.flowObj.opts.changeRawDataBeforeSend;
1388+
if (typeof changeRawDataBeforeSend === 'function') {
1389+
data = changeRawDataBeforeSend(this, data);
1390+
}
13791391
this.xhr.send(data);
13801392
},
13811393

@@ -1617,7 +1629,7 @@
16171629
* Library version
16181630
* @type {string}
16191631
*/
1620-
Flow.version = '2.13.2';
1632+
Flow.version = '2.14.0';
16211633

16221634
if ( typeof module === "object" && module && typeof module.exports === "object" ) {
16231635
// Expose Flow as module.exports in loaders that implement the Node

0 commit comments

Comments
 (0)