Skip to content

Commit f17be82

Browse files
committed
Merge pull request mailru#101 from wingedfox/master
Fixed append after abort
2 parents 685caaf + 7066521 commit f17be82

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,16 @@ Client explicitly sets the following headers:
485485
Any other headers are set by a target browser and are not used by client.
486486
Library does not provide any facilities to track a file uniqueness across requests, it's left on developer's consideration.
487487

488-
Client recognizes the following response codes:
489-
* 200, 201 - chunk is successfully saved
490-
* 416, 500 - recoverable error, library tries to resend chunk 'chunkUploadRetry' times then fails
488+
Response codes:
489+
* 200 - last chunk is uploaded
490+
* 201 - chunk is successfully saved
491+
* 416 - range is not acceptable error, recoverable
492+
* 500 - server error, recoverable
493+
494+
For recoverable errors server tries to resend chunk 'chunkUploadRetry' times then fails.
495+
496+
Response headers:
497+
* X-Last-Known-Byte: int, library tries to resend chunk from the given offset. Applicable to response codes 200 and 416
491498

492499
All the other codes - fatal error, user's involvement is recommend.
493500

lib/FileAPI.core.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
html5: true,
6363
debug: false,
6464
pingUrl: false,
65+
flashAbortTimeout: 0,
6566
withCredentials: true,
6667

6768
staticPath: './',
@@ -785,6 +786,7 @@
785786
// Set upload status props
786787
proxyXHR.total = _total;
787788
proxyXHR.loaded = 0;
789+
proxyXHR.filesLeft = dataArray.length;
788790

789791
// emit "beforeupload" event
790792
options.beforeupload(proxyXHR, options);
@@ -797,6 +799,8 @@
797799
, _fileOptions = _simpleClone(options)
798800
;
799801

802+
proxyXHR.filesLeft = dataArray.length;
803+
800804
if( _file && _file.name === api.expando ){
801805
_file = null;
802806
api.log('[warn] FileAPI.upload() — called without files')
@@ -872,7 +876,7 @@
872876

873877

874878
// ...
875-
proxyXHR.abort = function (current){ this.current = current; xhr.abort(); };
879+
proxyXHR.abort = function (current){ dataArray.length = 0; this.current = current; xhr.abort(); };
876880

877881
// Start upload
878882
xhr.send(form);
@@ -900,6 +904,8 @@
900904
}
901905
});
902906

907+
proxyXHR.statusText = "";
908+
903909
if (_complete) {
904910
_nextFile.call(_this);
905911
}

0 commit comments

Comments
 (0)