Skip to content

Commit ea3619a

Browse files
committed
feat: allow custom success status (200,201,202)
#52
1 parent 7aafa89 commit ea3619a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/flow.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @param {number} [opts.maxChunkRetries]
2525
* @param {number} [opts.chunkRetryInterval]
2626
* @param {Array.<number>} [opts.permanentErrors]
27+
* @param {Array.<number>} [opts.successStatuses]
2728
* @param {Function} [opts.generateUniqueIdentifier]
2829
* @constructor
2930
*/
@@ -82,6 +83,7 @@
8283
maxChunkRetries: 0,
8384
chunkRetryInterval: null,
8485
permanentErrors: [404, 415, 500, 501],
86+
successStatuses: [200, 201, 202],
8587
onDropStopPropagation: false
8688
};
8789

@@ -1314,9 +1316,9 @@
13141316
// or 'LOADING' - meaning that stuff is happening
13151317
return 'uploading';
13161318
} else {
1317-
if (this.xhr.status == 200 || this.xhr.status == 202) {
1319+
if (this.flowObj.opts.successStatuses.indexOf(this.xhr.status) > -1) {
13181320
// HTTP 200, perfect
1319-
// HTTP 202 Accepted - The request has been accepted for processing, but the processing has not been completed.
1321+
// HTTP 202 Accepted - The request has been accepted for processing, but the processing has not been completed.
13201322
return 'success';
13211323
} else if (this.flowObj.opts.permanentErrors.indexOf(this.xhr.status) > -1 ||
13221324
this.retries >= this.flowObj.opts.maxChunkRetries) {

0 commit comments

Comments
 (0)