|
1422 | 1422 | SignedS3AWSRequest.prototype.send.call(self);
|
1423 | 1423 | });
|
1424 | 1424 | }
|
| 1425 | + return Promise.resolve(); |
1425 | 1426 | };
|
1426 | 1427 | PutPart.prototype.success = function () {
|
1427 | 1428 | clearInterval(this.stalledInterval);
|
|
1467 | 1468 | return [CANCELED, ABORTED, PAUSED, PAUSING].indexOf(this.fileUpload.status) > -1;
|
1468 | 1469 | };
|
1469 | 1470 | PutPart.prototype.delaySend = function () {
|
| 1471 | + var that = this; |
1470 | 1472 | var backOffWait = this.backOffWait();
|
1471 | 1473 | this.attempts += 1;
|
1472 |
| - setTimeout(this.send.bind(this), backOffWait); |
| 1474 | + setTimeout(function() { |
| 1475 | + that.send().catch( |
| 1476 | + function(e) { |
| 1477 | + l.w(e); |
| 1478 | + }); |
| 1479 | + }, backOffWait); |
1473 | 1480 | };
|
1474 | 1481 | PutPart.prototype.errorHandler = function (reason) {
|
1475 | 1482 | clearInterval(this.stalledInterval);
|
1476 |
| - if (reason.match(/status:404/)) { |
1477 |
| - var errMsg = '404 error on part PUT. The part and the file will abort. ' + reason; |
| 1483 | + var hasError = false; |
| 1484 | + var errMsg = "Unexpected error occured"; |
| 1485 | + if (reason instanceof DOMException) { |
| 1486 | + this.fileUpload.stopMonitor(); |
| 1487 | + errMsg = "Error reading file. " + reason; |
| 1488 | + hasError = true; |
| 1489 | + } |
| 1490 | + else if (reason.match(/status:404/)) { |
| 1491 | + errMsg = '404 error on part PUT. The part and the file will abort. ' + reason; |
| 1492 | + hasError = true; |
| 1493 | + } |
| 1494 | + |
| 1495 | + if (hasError) { |
1478 | 1496 | l.w(errMsg);
|
1479 | 1497 | this.fileUpload.error(errMsg);
|
1480 | 1498 | this.part.status = ABORTED;
|
|
1560 | 1578 | slicerFn = (file.slice ? 'slice' : (file.mozSlice ? 'mozSlice' : 'webkitSlice')),
|
1561 | 1579 | blob = file[slicerFn](this.start, this.end);
|
1562 | 1580 | if (this.con.computeContentMd5) {
|
1563 |
| - return new Promise(function (resolve) { |
| 1581 | + return new Promise(function (resolve, reject) { |
1564 | 1582 | var reader = new FileReader();
|
1565 | 1583 | reader.onloadend = function () {
|
| 1584 | + if (this.error) { |
| 1585 | + that.errorHandler(this.error); |
| 1586 | + reject(this.error.message); |
| 1587 | + return; |
| 1588 | + } |
1566 | 1589 | var buffer = this.result && typeof this.result.buffer !== 'undefined',
|
1567 | 1590 | result = buffer ? new Uint8Array(this.result.buffer) : this.result;
|
1568 | 1591 | resolve(result);
|
1569 | 1592 | };
|
1570 |
| - reader.onerror = function() { |
1571 |
| - that.fileUpload.error("Problem occured while reading file " + file.name); |
1572 |
| - }; |
1573 | 1593 | reader.readAsArrayBuffer(blob);
|
1574 | 1594 | });
|
1575 | 1595 | }
|
|
0 commit comments