|
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] |
|
750 | 750 | * @type {string} |
751 | 751 | */ |
752 | 752 | this.uniqueIdentifier = (uniqueIdentifier === undefined ? flowObj.generateUniqueIdentifier(file) : uniqueIdentifier); |
| 753 | + |
| 754 | + /** |
| 755 | + * Size of Each Chunk |
| 756 | + * @type {number} |
| 757 | + */ |
| 758 | + this.chunkSize = 0; |
753 | 759 |
|
754 | 760 | /** |
755 | 761 | * List of chunks |
|
938 | 944 | // Rebuild stack of chunks from file |
939 | 945 | this._prevProgress = 0; |
940 | 946 | var round = this.flowObj.opts.forceChunkSize ? Math.ceil : Math.floor; |
| 947 | + this.chunkSize = evalOpts(this.flowObj.opts.chunkSize, this); |
941 | 948 | var chunks = Math.max( |
942 | | - round(this.size / this.flowObj.opts.chunkSize), 1 |
| 949 | + round(this.size / this.chunkSize), 1 |
943 | 950 | ); |
944 | 951 | for (var offset = 0; offset < chunks; offset++) { |
945 | 952 | this.chunks.push( |
|
1153 | 1160 | * Size of a chunk |
1154 | 1161 | * @type {number} |
1155 | 1162 | */ |
1156 | | - this.chunkSize = this.flowObj.opts.chunkSize; |
| 1163 | + this.chunkSize = this.fileObj.chunkSize; |
1157 | 1164 |
|
1158 | 1165 | /** |
1159 | 1166 | * Chunk start byte in a file |
|
1267 | 1274 | getParams: function () { |
1268 | 1275 | return { |
1269 | 1276 | flowChunkNumber: this.offset + 1, |
1270 | | - flowChunkSize: this.flowObj.opts.chunkSize, |
| 1277 | + flowChunkSize: this.chunkSize, |
1271 | 1278 | flowCurrentChunkSize: this.endByte - this.startByte, |
1272 | 1279 | flowTotalSize: this.fileObj.size, |
1273 | 1280 | flowIdentifier: this.fileObj.uniqueIdentifier, |
|
0 commit comments