|
12 | 12 | * Flow.js is a library providing multiple simultaneous, stable and
|
13 | 13 | * resumable uploads via the HTML5 File API.
|
14 | 14 | * @param [opts]
|
15 |
| - * @param {number} [opts.chunkSize] |
| 15 | + * @param {number|Function} [opts.chunkSize] |
16 | 16 | * @param {bool} [opts.forceChunkSize]
|
17 | 17 | * @param {number} [opts.simultaneousUploads]
|
18 | 18 | * @param {bool} [opts.singleFile]
|
|
89 | 89 | headers: {},
|
90 | 90 | withCredentials: false,
|
91 | 91 | preprocess: null,
|
| 92 | + changeRawDataBeforeSend: null, |
92 | 93 | method: 'multipart',
|
93 | 94 | testMethod: 'GET',
|
94 | 95 | uploadMethod: 'POST',
|
|
749 | 750 | * @type {string}
|
750 | 751 | */
|
751 | 752 | this.uniqueIdentifier = (uniqueIdentifier === undefined ? flowObj.generateUniqueIdentifier(file) : uniqueIdentifier);
|
| 753 | + |
| 754 | + /** |
| 755 | + * Size of Each Chunk |
| 756 | + * @type {number} |
| 757 | + */ |
| 758 | + this.chunkSize = 0; |
752 | 759 |
|
753 | 760 | /**
|
754 | 761 | * List of chunks
|
|
937 | 944 | // Rebuild stack of chunks from file
|
938 | 945 | this._prevProgress = 0;
|
939 | 946 | var round = this.flowObj.opts.forceChunkSize ? Math.ceil : Math.floor;
|
| 947 | + this.chunkSize = evalOpts(this.flowObj.opts.chunkSize, this); |
940 | 948 | var chunks = Math.max(
|
941 |
| - round(this.size / this.flowObj.opts.chunkSize), 1 |
| 949 | + round(this.size / this.chunkSize), 1 |
942 | 950 | );
|
943 | 951 | for (var offset = 0; offset < chunks; offset++) {
|
944 | 952 | this.chunks.push(
|
|
1152 | 1160 | * Size of a chunk
|
1153 | 1161 | * @type {number}
|
1154 | 1162 | */
|
1155 |
| - this.chunkSize = this.flowObj.opts.chunkSize; |
| 1163 | + this.chunkSize = this.fileObj.chunkSize; |
1156 | 1164 |
|
1157 | 1165 | /**
|
1158 | 1166 | * Chunk start byte in a file
|
|
1266 | 1274 | getParams: function () {
|
1267 | 1275 | return {
|
1268 | 1276 | flowChunkNumber: this.offset + 1,
|
1269 |
| - flowChunkSize: this.flowObj.opts.chunkSize, |
| 1277 | + flowChunkSize: this.chunkSize, |
1270 | 1278 | flowCurrentChunkSize: this.endByte - this.startByte,
|
1271 | 1279 | flowTotalSize: this.fileObj.size,
|
1272 | 1280 | flowIdentifier: this.fileObj.uniqueIdentifier,
|
|
1376 | 1384 |
|
1377 | 1385 | var uploadMethod = evalOpts(this.flowObj.opts.uploadMethod, this.fileObj, this);
|
1378 | 1386 | 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 | + } |
1379 | 1391 | this.xhr.send(data);
|
1380 | 1392 | },
|
1381 | 1393 |
|
|
1617 | 1629 | * Library version
|
1618 | 1630 | * @type {string}
|
1619 | 1631 | */
|
1620 |
| - Flow.version = '2.13.2'; |
| 1632 | + Flow.version = '2.14.0'; |
1621 | 1633 |
|
1622 | 1634 | if ( typeof module === "object" && module && typeof module.exports === "object" ) {
|
1623 | 1635 | // Expose Flow as module.exports in loaders that implement the Node
|
|
0 commit comments