Skip to content

Commit 068edf1

Browse files
author
Raphaël Droz
committed
Per-chunk filenames
Use: query: (fileObj, chunk) => { // Upload "foobar.bin" first chunk at "segments/000-foobar.bin" chunk.filename = 'segments/' + chunk.offset.toString().padStart(3, 0) + '-' + fileObj.file.name; }
1 parent de28124 commit 068edf1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/flow.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,12 @@
11691169
*/
11701170
this.startByte = this.offset * this.chunkSize;
11711171

1172+
/**
1173+
* A specific filename for this chunk which otherwise default to the main name
1174+
* @type {string}
1175+
*/
1176+
this.filename = null;
1177+
11721178
/**
11731179
* Compute the endbyte in a file
11741180
*
@@ -1512,7 +1518,9 @@
15121518
each(query, function (v, k) {
15131519
data.append(k, v);
15141520
});
1515-
if (typeof blob !== "undefined") data.append(this.flowObj.opts.fileParameterName, blob, this.fileObj.file.name);
1521+
if (typeof blob !== "undefined") {
1522+
data.append(this.flowObj.opts.fileParameterName, blob, this.filename || this.fileObj.file.name);
1523+
}
15161524
}
15171525

15181526
this.xhr.open(method, target, true);

0 commit comments

Comments
 (0)