@aws-amplify/storage 4.5.9-unstable.7 → 4.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -410,12 +410,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
410
410
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/crc32/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
411
411
|
|
|
412
412
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
};
|
|
416
|
-
var toUtf8 = function (input) {
|
|
417
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
418
|
-
};
|
|
413
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
414
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
419
415
|
|
|
420
416
|
|
|
421
417
|
/***/ }),
|
|
@@ -431,44 +427,44 @@ var toUtf8 = function (input) {
|
|
|
431
427
|
__webpack_require__.r(__webpack_exports__);
|
|
432
428
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
433
429
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
for (
|
|
437
|
-
|
|
430
|
+
const fromUtf8 = (input) => {
|
|
431
|
+
const bytes = [];
|
|
432
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
433
|
+
const value = input.charCodeAt(i);
|
|
438
434
|
if (value < 0x80) {
|
|
439
435
|
bytes.push(value);
|
|
440
436
|
}
|
|
441
437
|
else if (value < 0x800) {
|
|
442
|
-
bytes.push((value >> 6) |
|
|
438
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
443
439
|
}
|
|
444
440
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
445
|
-
|
|
446
|
-
bytes.push((surrogatePair >> 18) |
|
|
441
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
442
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
447
443
|
}
|
|
448
444
|
else {
|
|
449
|
-
bytes.push((value >> 12) |
|
|
445
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
450
446
|
}
|
|
451
447
|
}
|
|
452
448
|
return Uint8Array.from(bytes);
|
|
453
449
|
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
for (
|
|
457
|
-
|
|
450
|
+
const toUtf8 = (input) => {
|
|
451
|
+
let decoded = "";
|
|
452
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
453
|
+
const byte = input[i];
|
|
458
454
|
if (byte < 0x80) {
|
|
459
455
|
decoded += String.fromCharCode(byte);
|
|
460
456
|
}
|
|
461
|
-
else if (
|
|
462
|
-
|
|
463
|
-
decoded += String.fromCharCode(((byte &
|
|
457
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
458
|
+
const nextByte = input[++i];
|
|
459
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
464
460
|
}
|
|
465
|
-
else if (
|
|
466
|
-
|
|
467
|
-
|
|
461
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
462
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
463
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
468
464
|
decoded += decodeURIComponent(encoded);
|
|
469
465
|
}
|
|
470
466
|
else {
|
|
471
|
-
decoded += String.fromCharCode(((byte &
|
|
467
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
472
468
|
}
|
|
473
469
|
}
|
|
474
470
|
return decoded;
|
|
@@ -1060,12 +1056,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1060
1056
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/sha256-browser/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
1061
1057
|
|
|
1062
1058
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
};
|
|
1066
|
-
var toUtf8 = function (input) {
|
|
1067
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1068
|
-
};
|
|
1059
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
1060
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1069
1061
|
|
|
1070
1062
|
|
|
1071
1063
|
/***/ }),
|
|
@@ -1081,44 +1073,44 @@ var toUtf8 = function (input) {
|
|
|
1081
1073
|
__webpack_require__.r(__webpack_exports__);
|
|
1082
1074
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
1083
1075
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
for (
|
|
1087
|
-
|
|
1076
|
+
const fromUtf8 = (input) => {
|
|
1077
|
+
const bytes = [];
|
|
1078
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1079
|
+
const value = input.charCodeAt(i);
|
|
1088
1080
|
if (value < 0x80) {
|
|
1089
1081
|
bytes.push(value);
|
|
1090
1082
|
}
|
|
1091
1083
|
else if (value < 0x800) {
|
|
1092
|
-
bytes.push((value >> 6) |
|
|
1084
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
1093
1085
|
}
|
|
1094
1086
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
1095
|
-
|
|
1096
|
-
bytes.push((surrogatePair >> 18) |
|
|
1087
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
1088
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
1097
1089
|
}
|
|
1098
1090
|
else {
|
|
1099
|
-
bytes.push((value >> 12) |
|
|
1091
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
1100
1092
|
}
|
|
1101
1093
|
}
|
|
1102
1094
|
return Uint8Array.from(bytes);
|
|
1103
1095
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
for (
|
|
1107
|
-
|
|
1096
|
+
const toUtf8 = (input) => {
|
|
1097
|
+
let decoded = "";
|
|
1098
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1099
|
+
const byte = input[i];
|
|
1108
1100
|
if (byte < 0x80) {
|
|
1109
1101
|
decoded += String.fromCharCode(byte);
|
|
1110
1102
|
}
|
|
1111
|
-
else if (
|
|
1112
|
-
|
|
1113
|
-
decoded += String.fromCharCode(((byte &
|
|
1103
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
1104
|
+
const nextByte = input[++i];
|
|
1105
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
1114
1106
|
}
|
|
1115
|
-
else if (
|
|
1116
|
-
|
|
1117
|
-
|
|
1107
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
1108
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
1109
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
1118
1110
|
decoded += decodeURIComponent(encoded);
|
|
1119
1111
|
}
|
|
1120
1112
|
else {
|
|
1121
|
-
decoded += String.fromCharCode(((byte &
|
|
1113
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
1122
1114
|
}
|
|
1123
1115
|
}
|
|
1124
1116
|
return decoded;
|
|
@@ -1655,12 +1647,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1655
1647
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/sha256-js/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
1656
1648
|
|
|
1657
1649
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
};
|
|
1661
|
-
var toUtf8 = function (input) {
|
|
1662
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1663
|
-
};
|
|
1650
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
1651
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1664
1652
|
|
|
1665
1653
|
|
|
1666
1654
|
/***/ }),
|
|
@@ -1676,44 +1664,44 @@ var toUtf8 = function (input) {
|
|
|
1676
1664
|
__webpack_require__.r(__webpack_exports__);
|
|
1677
1665
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
1678
1666
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
for (
|
|
1682
|
-
|
|
1667
|
+
const fromUtf8 = (input) => {
|
|
1668
|
+
const bytes = [];
|
|
1669
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1670
|
+
const value = input.charCodeAt(i);
|
|
1683
1671
|
if (value < 0x80) {
|
|
1684
1672
|
bytes.push(value);
|
|
1685
1673
|
}
|
|
1686
1674
|
else if (value < 0x800) {
|
|
1687
|
-
bytes.push((value >> 6) |
|
|
1675
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
1688
1676
|
}
|
|
1689
1677
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
1690
|
-
|
|
1691
|
-
bytes.push((surrogatePair >> 18) |
|
|
1678
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
1679
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
1692
1680
|
}
|
|
1693
1681
|
else {
|
|
1694
|
-
bytes.push((value >> 12) |
|
|
1682
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
1695
1683
|
}
|
|
1696
1684
|
}
|
|
1697
1685
|
return Uint8Array.from(bytes);
|
|
1698
1686
|
};
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
for (
|
|
1702
|
-
|
|
1687
|
+
const toUtf8 = (input) => {
|
|
1688
|
+
let decoded = "";
|
|
1689
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1690
|
+
const byte = input[i];
|
|
1703
1691
|
if (byte < 0x80) {
|
|
1704
1692
|
decoded += String.fromCharCode(byte);
|
|
1705
1693
|
}
|
|
1706
|
-
else if (
|
|
1707
|
-
|
|
1708
|
-
decoded += String.fromCharCode(((byte &
|
|
1694
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
1695
|
+
const nextByte = input[++i];
|
|
1696
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
1709
1697
|
}
|
|
1710
|
-
else if (
|
|
1711
|
-
|
|
1712
|
-
|
|
1698
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
1699
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
1700
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
1713
1701
|
decoded += decodeURIComponent(encoded);
|
|
1714
1702
|
}
|
|
1715
1703
|
else {
|
|
1716
|
-
decoded += String.fromCharCode(((byte &
|
|
1704
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
1717
1705
|
}
|
|
1718
1706
|
}
|
|
1719
1707
|
return decoded;
|
|
@@ -40112,7 +40100,7 @@ function calculateBodyLength(body) {
|
|
|
40112
40100
|
"use strict";
|
|
40113
40101
|
__webpack_require__.r(__webpack_exports__);
|
|
40114
40102
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "locateWindow", function() { return locateWindow; });
|
|
40115
|
-
|
|
40103
|
+
const fallbackWindow = {};
|
|
40116
40104
|
function locateWindow() {
|
|
40117
40105
|
if (typeof window !== "undefined") {
|
|
40118
40106
|
return window;
|
|
@@ -47984,26 +47972,21 @@ var __assign = undefined && undefined.__assign || function () {
|
|
|
47984
47972
|
__assign = Object.assign || function (t) {
|
|
47985
47973
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
47986
47974
|
s = arguments[i];
|
|
47987
|
-
|
|
47988
47975
|
for (var p in s) {
|
|
47989
47976
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
47990
47977
|
}
|
|
47991
47978
|
}
|
|
47992
|
-
|
|
47993
47979
|
return t;
|
|
47994
47980
|
};
|
|
47995
|
-
|
|
47996
47981
|
return __assign.apply(this, arguments);
|
|
47997
47982
|
};
|
|
47998
|
-
|
|
47999
47983
|
var __read = undefined && undefined.__read || function (o, n) {
|
|
48000
47984
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
48001
47985
|
if (!m) return o;
|
|
48002
47986
|
var i = m.call(o),
|
|
48003
|
-
|
|
48004
|
-
|
|
48005
|
-
|
|
48006
|
-
|
|
47987
|
+
r,
|
|
47988
|
+
ar = [],
|
|
47989
|
+
e;
|
|
48007
47990
|
try {
|
|
48008
47991
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
48009
47992
|
ar.push(r.value);
|
|
@@ -48019,23 +48002,18 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
48019
48002
|
if (e) throw e.error;
|
|
48020
48003
|
}
|
|
48021
48004
|
}
|
|
48022
|
-
|
|
48023
48005
|
return ar;
|
|
48024
48006
|
};
|
|
48025
48007
|
|
|
48026
48008
|
|
|
48027
48009
|
|
|
48028
48010
|
|
|
48029
|
-
|
|
48030
48011
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('StorageClass');
|
|
48031
48012
|
var DEFAULT_PROVIDER = 'AWSS3';
|
|
48032
48013
|
/**
|
|
48033
48014
|
* Provide storage methods to use AWS S3
|
|
48034
48015
|
*/
|
|
48035
|
-
|
|
48036
|
-
var Storage =
|
|
48037
|
-
/** @class */
|
|
48038
|
-
function () {
|
|
48016
|
+
var Storage = /** @class */function () {
|
|
48039
48017
|
/**
|
|
48040
48018
|
* Initialize Storage
|
|
48041
48019
|
* @param {Object} config - Configuration object for storage
|
|
@@ -48050,7 +48028,6 @@ function () {
|
|
|
48050
48028
|
this.remove = this.remove.bind(this);
|
|
48051
48029
|
this.list = this.list.bind(this);
|
|
48052
48030
|
}
|
|
48053
|
-
|
|
48054
48031
|
Storage.prototype.getModuleName = function () {
|
|
48055
48032
|
return 'Storage';
|
|
48056
48033
|
};
|
|
@@ -48058,12 +48035,9 @@ function () {
|
|
|
48058
48035
|
* add plugin into Storage category
|
|
48059
48036
|
* @param {Object} pluggable - an instance of the plugin
|
|
48060
48037
|
*/
|
|
48061
|
-
|
|
48062
|
-
|
|
48063
48038
|
Storage.prototype.addPluggable = function (pluggable) {
|
|
48064
48039
|
if (pluggable && pluggable.getCategory() === 'Storage') {
|
|
48065
48040
|
this._pluggables.push(pluggable);
|
|
48066
|
-
|
|
48067
48041
|
var config = {};
|
|
48068
48042
|
config = pluggable.configure(this._config[pluggable.getProviderName()]);
|
|
48069
48043
|
return config;
|
|
@@ -48073,13 +48047,10 @@ function () {
|
|
|
48073
48047
|
* Get the plugin object
|
|
48074
48048
|
* @param providerName - the name of the plugin
|
|
48075
48049
|
*/
|
|
48076
|
-
|
|
48077
|
-
|
|
48078
48050
|
Storage.prototype.getPluggable = function (providerName) {
|
|
48079
48051
|
var pluggable = this._pluggables.find(function (pluggable) {
|
|
48080
48052
|
return pluggable.getProviderName() === providerName;
|
|
48081
48053
|
});
|
|
48082
|
-
|
|
48083
48054
|
if (pluggable === undefined) {
|
|
48084
48055
|
logger.debug('No plugin found with providerName', providerName);
|
|
48085
48056
|
return null;
|
|
@@ -48089,8 +48060,6 @@ function () {
|
|
|
48089
48060
|
* Remove the plugin object
|
|
48090
48061
|
* @param providerName - the name of the plugin
|
|
48091
48062
|
*/
|
|
48092
|
-
|
|
48093
|
-
|
|
48094
48063
|
Storage.prototype.removePluggable = function (providerName) {
|
|
48095
48064
|
this._pluggables = this._pluggables.filter(function (pluggable) {
|
|
48096
48065
|
return pluggable.getProviderName() !== providerName;
|
|
@@ -48102,124 +48071,97 @@ function () {
|
|
|
48102
48071
|
* @param {Object} config - Configuration object for storage
|
|
48103
48072
|
* @return {Object} - Current configuration
|
|
48104
48073
|
*/
|
|
48105
|
-
|
|
48106
|
-
|
|
48107
48074
|
Storage.prototype.configure = function (config) {
|
|
48108
48075
|
var _this = this;
|
|
48109
|
-
|
|
48110
48076
|
logger.debug('configure Storage');
|
|
48111
48077
|
if (!config) return this._config;
|
|
48112
48078
|
var amplifyConfig = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Parser"].parseMobilehubConfig(config);
|
|
48113
48079
|
var storageKeysFromConfig = Object.keys(amplifyConfig.Storage);
|
|
48114
48080
|
var storageArrayKeys = ['bucket', 'region', 'level', 'track', 'customPrefix', 'serverSideEncryption', 'SSECustomerAlgorithm', 'SSECustomerKey', 'SSECustomerKeyMD5', 'SSEKMSKeyId'];
|
|
48115
|
-
|
|
48116
48081
|
var isInStorageArrayKeys = function isInStorageArrayKeys(k) {
|
|
48117
48082
|
return storageArrayKeys.some(function (x) {
|
|
48118
48083
|
return x === k;
|
|
48119
48084
|
});
|
|
48120
48085
|
};
|
|
48121
|
-
|
|
48122
48086
|
var checkConfigKeysFromArray = function checkConfigKeysFromArray(k) {
|
|
48123
48087
|
return k.find(function (k) {
|
|
48124
48088
|
return isInStorageArrayKeys(k);
|
|
48125
48089
|
});
|
|
48126
48090
|
};
|
|
48127
|
-
|
|
48128
48091
|
if (storageKeysFromConfig && checkConfigKeysFromArray(storageKeysFromConfig) && !amplifyConfig.Storage[DEFAULT_PROVIDER]) {
|
|
48129
48092
|
amplifyConfig.Storage[DEFAULT_PROVIDER] = {};
|
|
48130
48093
|
}
|
|
48131
|
-
|
|
48132
48094
|
Object.entries(amplifyConfig.Storage).map(function (_a) {
|
|
48133
48095
|
var _b = __read(_a, 2),
|
|
48134
|
-
|
|
48135
|
-
|
|
48136
|
-
|
|
48096
|
+
key = _b[0],
|
|
48097
|
+
value = _b[1];
|
|
48137
48098
|
if (key && isInStorageArrayKeys(key) && value !== undefined) {
|
|
48138
48099
|
amplifyConfig.Storage[DEFAULT_PROVIDER][key] = value;
|
|
48139
48100
|
delete amplifyConfig.Storage[key];
|
|
48140
48101
|
}
|
|
48141
|
-
});
|
|
48142
|
-
|
|
48102
|
+
});
|
|
48103
|
+
// only update new values for each provider
|
|
48143
48104
|
Object.keys(amplifyConfig.Storage).forEach(function (providerName) {
|
|
48144
48105
|
if (typeof amplifyConfig.Storage[providerName] !== 'string') {
|
|
48145
48106
|
_this._config[providerName] = __assign(__assign({}, _this._config[providerName]), amplifyConfig.Storage[providerName]);
|
|
48146
48107
|
}
|
|
48147
48108
|
});
|
|
48148
|
-
|
|
48149
48109
|
this._pluggables.forEach(function (pluggable) {
|
|
48150
48110
|
pluggable.configure(_this._config[pluggable.getProviderName()]);
|
|
48151
48111
|
});
|
|
48152
|
-
|
|
48153
48112
|
if (this._pluggables.length === 0) {
|
|
48154
48113
|
this.addPluggable(new _providers__WEBPACK_IMPORTED_MODULE_1__["AWSS3Provider"]());
|
|
48155
48114
|
}
|
|
48156
|
-
|
|
48157
48115
|
return this._config;
|
|
48158
48116
|
};
|
|
48159
|
-
|
|
48160
48117
|
Storage.prototype.getCancellableTokenSource = function () {
|
|
48161
48118
|
return axios__WEBPACK_IMPORTED_MODULE_2___default.a.CancelToken.source();
|
|
48162
48119
|
};
|
|
48163
|
-
|
|
48164
48120
|
Storage.prototype.updateRequestToBeCancellable = function (request, cancelTokenSource) {
|
|
48165
48121
|
this._cancelTokenSourceMap.set(request, cancelTokenSource);
|
|
48166
48122
|
};
|
|
48167
|
-
|
|
48168
48123
|
Storage.prototype.isUploadTask = function (x) {
|
|
48169
48124
|
return typeof x !== 'undefined' && typeof x['pause'] === 'function' && typeof x['resume'] === 'function';
|
|
48170
48125
|
};
|
|
48171
|
-
|
|
48172
48126
|
Storage.prototype.cancel = function (request, message) {
|
|
48173
48127
|
if (request instanceof _providers_AWSS3UploadTask__WEBPACK_IMPORTED_MODULE_3__["AWSS3UploadTask"]) {
|
|
48174
48128
|
return request._cancel();
|
|
48175
48129
|
}
|
|
48176
|
-
|
|
48177
48130
|
var cancelTokenSource = this._cancelTokenSourceMap.get(request);
|
|
48178
|
-
|
|
48179
48131
|
if (cancelTokenSource) {
|
|
48180
48132
|
cancelTokenSource.cancel(message);
|
|
48181
48133
|
} else {
|
|
48182
48134
|
logger.debug('The request does not map to any cancel token');
|
|
48183
48135
|
}
|
|
48184
48136
|
};
|
|
48185
|
-
|
|
48186
48137
|
Storage.prototype.copy = function (src, dest, config) {
|
|
48187
48138
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
48188
|
-
|
|
48189
48139
|
var prov = this._pluggables.find(function (pluggable) {
|
|
48190
48140
|
return pluggable.getProviderName() === provider;
|
|
48191
48141
|
});
|
|
48192
|
-
|
|
48193
48142
|
if (prov === undefined) {
|
|
48194
48143
|
logger.debug('No plugin found with providerName', provider);
|
|
48195
48144
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
48196
48145
|
}
|
|
48197
|
-
|
|
48198
48146
|
var cancelTokenSource = this.getCancellableTokenSource();
|
|
48199
|
-
|
|
48200
48147
|
if (typeof prov.copy !== 'function') {
|
|
48201
48148
|
return Promise.reject(".copy is not implemented on provider " + prov.getProviderName());
|
|
48202
48149
|
}
|
|
48203
|
-
|
|
48204
48150
|
var responsePromise = prov.copy(src, dest, __assign(__assign({}, config), {
|
|
48205
48151
|
cancelTokenSource: cancelTokenSource
|
|
48206
48152
|
}));
|
|
48207
48153
|
this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);
|
|
48208
48154
|
return responsePromise;
|
|
48209
48155
|
};
|
|
48210
|
-
|
|
48211
48156
|
Storage.prototype.get = function (key, config) {
|
|
48212
48157
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
48213
|
-
|
|
48214
48158
|
var prov = this._pluggables.find(function (pluggable) {
|
|
48215
48159
|
return pluggable.getProviderName() === provider;
|
|
48216
48160
|
});
|
|
48217
|
-
|
|
48218
48161
|
if (prov === undefined) {
|
|
48219
48162
|
logger.debug('No plugin found with providerName', provider);
|
|
48220
48163
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
48221
48164
|
}
|
|
48222
|
-
|
|
48223
48165
|
var cancelTokenSource = this.getCancellableTokenSource();
|
|
48224
48166
|
var responsePromise = prov.get(key, __assign(__assign({}, config), {
|
|
48225
48167
|
cancelTokenSource: cancelTokenSource
|
|
@@ -48227,73 +48169,55 @@ function () {
|
|
|
48227
48169
|
this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);
|
|
48228
48170
|
return responsePromise;
|
|
48229
48171
|
};
|
|
48230
|
-
|
|
48231
48172
|
Storage.prototype.isCancelError = function (error) {
|
|
48232
48173
|
return axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error);
|
|
48233
48174
|
};
|
|
48234
|
-
|
|
48235
48175
|
Storage.prototype.put = function (key, object, config) {
|
|
48236
48176
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
48237
|
-
|
|
48238
48177
|
var prov = this._pluggables.find(function (pluggable) {
|
|
48239
48178
|
return pluggable.getProviderName() === provider;
|
|
48240
48179
|
});
|
|
48241
|
-
|
|
48242
48180
|
if (prov === undefined) {
|
|
48243
48181
|
logger.debug('No plugin found with providerName', provider);
|
|
48244
48182
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
48245
48183
|
}
|
|
48246
|
-
|
|
48247
48184
|
var cancelTokenSource = this.getCancellableTokenSource();
|
|
48248
48185
|
var response = prov.put(key, object, __assign(__assign({}, config), {
|
|
48249
48186
|
cancelTokenSource: cancelTokenSource
|
|
48250
48187
|
}));
|
|
48251
|
-
|
|
48252
48188
|
if (!this.isUploadTask(response)) {
|
|
48253
48189
|
this.updateRequestToBeCancellable(response, cancelTokenSource);
|
|
48254
48190
|
}
|
|
48255
|
-
|
|
48256
48191
|
return response;
|
|
48257
48192
|
};
|
|
48258
|
-
|
|
48259
48193
|
Storage.prototype.remove = function (key, config) {
|
|
48260
48194
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
48261
|
-
|
|
48262
48195
|
var prov = this._pluggables.find(function (pluggable) {
|
|
48263
48196
|
return pluggable.getProviderName() === provider;
|
|
48264
48197
|
});
|
|
48265
|
-
|
|
48266
48198
|
if (prov === undefined) {
|
|
48267
48199
|
logger.debug('No plugin found with providerName', provider);
|
|
48268
48200
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
48269
48201
|
}
|
|
48270
|
-
|
|
48271
48202
|
return prov.remove(key, config);
|
|
48272
48203
|
};
|
|
48273
|
-
|
|
48274
48204
|
Storage.prototype.list = function (path, config) {
|
|
48275
48205
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
48276
|
-
|
|
48277
48206
|
var prov = this._pluggables.find(function (pluggable) {
|
|
48278
48207
|
return pluggable.getProviderName() === provider;
|
|
48279
48208
|
});
|
|
48280
|
-
|
|
48281
48209
|
if (prov === undefined) {
|
|
48282
48210
|
logger.debug('No plugin found with providerName', provider);
|
|
48283
48211
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
48284
48212
|
}
|
|
48285
|
-
|
|
48286
48213
|
return prov.list(path, config);
|
|
48287
48214
|
};
|
|
48288
|
-
|
|
48289
48215
|
return Storage;
|
|
48290
48216
|
}();
|
|
48291
48217
|
|
|
48292
|
-
|
|
48293
48218
|
/**
|
|
48294
48219
|
* @deprecated use named import
|
|
48295
48220
|
*/
|
|
48296
|
-
|
|
48297
48221
|
/* harmony default export */ __webpack_exports__["default"] = (Storage);
|
|
48298
48222
|
|
|
48299
48223
|
/***/ }),
|
|
@@ -48323,25 +48247,20 @@ var __assign = undefined && undefined.__assign || function () {
|
|
|
48323
48247
|
__assign = Object.assign || function (t) {
|
|
48324
48248
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
48325
48249
|
s = arguments[i];
|
|
48326
|
-
|
|
48327
48250
|
for (var p in s) {
|
|
48328
48251
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
48329
48252
|
}
|
|
48330
48253
|
}
|
|
48331
|
-
|
|
48332
48254
|
return t;
|
|
48333
48255
|
};
|
|
48334
|
-
|
|
48335
48256
|
return __assign.apply(this, arguments);
|
|
48336
48257
|
};
|
|
48337
|
-
|
|
48338
48258
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
48339
48259
|
function adopt(value) {
|
|
48340
48260
|
return value instanceof P ? value : new P(function (resolve) {
|
|
48341
48261
|
resolve(value);
|
|
48342
48262
|
});
|
|
48343
48263
|
}
|
|
48344
|
-
|
|
48345
48264
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48346
48265
|
function fulfilled(value) {
|
|
48347
48266
|
try {
|
|
@@ -48350,7 +48269,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
48350
48269
|
reject(e);
|
|
48351
48270
|
}
|
|
48352
48271
|
}
|
|
48353
|
-
|
|
48354
48272
|
function rejected(value) {
|
|
48355
48273
|
try {
|
|
48356
48274
|
step(generator["throw"](value));
|
|
@@ -48358,29 +48276,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
48358
48276
|
reject(e);
|
|
48359
48277
|
}
|
|
48360
48278
|
}
|
|
48361
|
-
|
|
48362
48279
|
function step(result) {
|
|
48363
48280
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
48364
48281
|
}
|
|
48365
|
-
|
|
48366
48282
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48367
48283
|
});
|
|
48368
48284
|
};
|
|
48369
|
-
|
|
48370
48285
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
48371
48286
|
var _ = {
|
|
48372
|
-
|
|
48373
|
-
|
|
48374
|
-
|
|
48375
|
-
|
|
48287
|
+
label: 0,
|
|
48288
|
+
sent: function sent() {
|
|
48289
|
+
if (t[0] & 1) throw t[1];
|
|
48290
|
+
return t[1];
|
|
48291
|
+
},
|
|
48292
|
+
trys: [],
|
|
48293
|
+
ops: []
|
|
48376
48294
|
},
|
|
48377
|
-
|
|
48378
|
-
|
|
48379
|
-
|
|
48380
|
-
|
|
48381
|
-
y,
|
|
48382
|
-
t,
|
|
48383
|
-
g;
|
|
48295
|
+
f,
|
|
48296
|
+
y,
|
|
48297
|
+
t,
|
|
48298
|
+
g;
|
|
48384
48299
|
return g = {
|
|
48385
48300
|
next: verb(0),
|
|
48386
48301
|
"throw": verb(1),
|
|
@@ -48388,79 +48303,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
48388
48303
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
48389
48304
|
return this;
|
|
48390
48305
|
}), g;
|
|
48391
|
-
|
|
48392
48306
|
function verb(n) {
|
|
48393
48307
|
return function (v) {
|
|
48394
48308
|
return step([n, v]);
|
|
48395
48309
|
};
|
|
48396
48310
|
}
|
|
48397
|
-
|
|
48398
48311
|
function step(op) {
|
|
48399
48312
|
if (f) throw new TypeError("Generator is already executing.");
|
|
48400
|
-
|
|
48401
48313
|
while (_) {
|
|
48402
48314
|
try {
|
|
48403
48315
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
48404
48316
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
48405
|
-
|
|
48406
48317
|
switch (op[0]) {
|
|
48407
48318
|
case 0:
|
|
48408
48319
|
case 1:
|
|
48409
48320
|
t = op;
|
|
48410
48321
|
break;
|
|
48411
|
-
|
|
48412
48322
|
case 4:
|
|
48413
48323
|
_.label++;
|
|
48414
48324
|
return {
|
|
48415
48325
|
value: op[1],
|
|
48416
48326
|
done: false
|
|
48417
48327
|
};
|
|
48418
|
-
|
|
48419
48328
|
case 5:
|
|
48420
48329
|
_.label++;
|
|
48421
48330
|
y = op[1];
|
|
48422
48331
|
op = [0];
|
|
48423
48332
|
continue;
|
|
48424
|
-
|
|
48425
48333
|
case 7:
|
|
48426
48334
|
op = _.ops.pop();
|
|
48427
|
-
|
|
48428
48335
|
_.trys.pop();
|
|
48429
|
-
|
|
48430
48336
|
continue;
|
|
48431
|
-
|
|
48432
48337
|
default:
|
|
48433
48338
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
48434
48339
|
_ = 0;
|
|
48435
48340
|
continue;
|
|
48436
48341
|
}
|
|
48437
|
-
|
|
48438
48342
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
48439
48343
|
_.label = op[1];
|
|
48440
48344
|
break;
|
|
48441
48345
|
}
|
|
48442
|
-
|
|
48443
48346
|
if (op[0] === 6 && _.label < t[1]) {
|
|
48444
48347
|
_.label = t[1];
|
|
48445
48348
|
t = op;
|
|
48446
48349
|
break;
|
|
48447
48350
|
}
|
|
48448
|
-
|
|
48449
48351
|
if (t && _.label < t[2]) {
|
|
48450
48352
|
_.label = t[2];
|
|
48451
|
-
|
|
48452
48353
|
_.ops.push(op);
|
|
48453
|
-
|
|
48454
48354
|
break;
|
|
48455
48355
|
}
|
|
48456
|
-
|
|
48457
48356
|
if (t[2]) _.ops.pop();
|
|
48458
|
-
|
|
48459
48357
|
_.trys.pop();
|
|
48460
|
-
|
|
48461
48358
|
continue;
|
|
48462
48359
|
}
|
|
48463
|
-
|
|
48464
48360
|
op = body.call(thisArg, _);
|
|
48465
48361
|
} catch (e) {
|
|
48466
48362
|
op = [6, e];
|
|
@@ -48469,7 +48365,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
48469
48365
|
f = t = 0;
|
|
48470
48366
|
}
|
|
48471
48367
|
}
|
|
48472
|
-
|
|
48473
48368
|
if (op[0] & 5) throw op[1];
|
|
48474
48369
|
return {
|
|
48475
48370
|
value: op[0] ? op[1] : void 0,
|
|
@@ -48481,31 +48376,27 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
48481
48376
|
|
|
48482
48377
|
|
|
48483
48378
|
|
|
48484
|
-
|
|
48485
|
-
|
|
48486
|
-
|
|
48379
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Logger"]('S3ClientUtils');
|
|
48380
|
+
// placeholder credentials in order to satisfy type requirement, always results in 403 when used
|
|
48487
48381
|
var INVALID_CRED = {
|
|
48488
48382
|
accessKeyId: '',
|
|
48489
48383
|
secretAccessKey: ''
|
|
48490
48384
|
};
|
|
48491
48385
|
var getPrefix = function getPrefix(config) {
|
|
48492
48386
|
var credentials = config.credentials,
|
|
48493
|
-
|
|
48494
|
-
|
|
48495
|
-
|
|
48387
|
+
level = config.level,
|
|
48388
|
+
customPrefix = config.customPrefix,
|
|
48389
|
+
identityId = config.identityId;
|
|
48496
48390
|
var resolvedCustomPrefix = customPrefix || {};
|
|
48497
48391
|
var resolvedIdentityId = identityId || credentials.identityId;
|
|
48498
48392
|
var privatePath = (resolvedCustomPrefix["private"] !== undefined ? resolvedCustomPrefix["private"] : 'private/') + resolvedIdentityId + '/';
|
|
48499
48393
|
var protectedPath = (resolvedCustomPrefix["protected"] !== undefined ? resolvedCustomPrefix["protected"] : 'protected/') + resolvedIdentityId + '/';
|
|
48500
48394
|
var publicPath = resolvedCustomPrefix["public"] !== undefined ? resolvedCustomPrefix["public"] : 'public/';
|
|
48501
|
-
|
|
48502
48395
|
switch (level) {
|
|
48503
48396
|
case 'private':
|
|
48504
48397
|
return privatePath;
|
|
48505
|
-
|
|
48506
48398
|
case 'protected':
|
|
48507
48399
|
return protectedPath;
|
|
48508
|
-
|
|
48509
48400
|
default:
|
|
48510
48401
|
return publicPath;
|
|
48511
48402
|
}
|
|
@@ -48518,10 +48409,7 @@ var createPrefixMiddleware = function createPrefixMiddleware(opt, key) {
|
|
|
48518
48409
|
return __generator(this, function (_a) {
|
|
48519
48410
|
switch (_a.label) {
|
|
48520
48411
|
case 0:
|
|
48521
|
-
return [4
|
|
48522
|
-
/*yield*/
|
|
48523
|
-
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
48524
|
-
|
|
48412
|
+
return [4 /*yield*/, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
48525
48413
|
case 1:
|
|
48526
48414
|
credentials = _a.sent();
|
|
48527
48415
|
cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials);
|
|
@@ -48529,7 +48417,6 @@ var createPrefixMiddleware = function createPrefixMiddleware(opt, key) {
|
|
|
48529
48417
|
credentials: cred
|
|
48530
48418
|
}));
|
|
48531
48419
|
clonedInput = Object.assign({}, args.input);
|
|
48532
|
-
|
|
48533
48420
|
if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) {
|
|
48534
48421
|
clonedInput.Key = prefix + key;
|
|
48535
48422
|
args.input = clonedInput;
|
|
@@ -48537,23 +48424,18 @@ var createPrefixMiddleware = function createPrefixMiddleware(opt, key) {
|
|
|
48537
48424
|
clonedInput.Prefix = prefix + key;
|
|
48538
48425
|
args.input = clonedInput;
|
|
48539
48426
|
}
|
|
48540
|
-
|
|
48541
48427
|
result = next(args);
|
|
48542
|
-
return [2
|
|
48543
|
-
/*return*/
|
|
48544
|
-
, result];
|
|
48428
|
+
return [2 /*return*/, result];
|
|
48545
48429
|
}
|
|
48546
48430
|
});
|
|
48547
48431
|
});
|
|
48548
48432
|
};
|
|
48549
48433
|
};
|
|
48550
48434
|
};
|
|
48551
|
-
|
|
48552
48435
|
var isTimeSkewedError = function isTimeSkewedError(err) {
|
|
48553
48436
|
return err.ServerTime && typeof err.Code === 'string' && err.Code === 'RequestTimeTooSkewed';
|
|
48554
|
-
};
|
|
48555
|
-
|
|
48556
|
-
|
|
48437
|
+
};
|
|
48438
|
+
// we want to take the S3Client config in parameter so we can modify it's systemClockOffset
|
|
48557
48439
|
var autoAdjustClockskewMiddleware = function autoAdjustClockskewMiddleware(config) {
|
|
48558
48440
|
return function (next, _context) {
|
|
48559
48441
|
return function (args) {
|
|
@@ -48563,36 +48445,25 @@ var autoAdjustClockskewMiddleware = function autoAdjustClockskewMiddleware(confi
|
|
|
48563
48445
|
switch (_a.label) {
|
|
48564
48446
|
case 0:
|
|
48565
48447
|
_a.trys.push([0, 2,, 3]);
|
|
48566
|
-
|
|
48567
|
-
return [4
|
|
48568
|
-
/*yield*/
|
|
48569
|
-
, next(args)];
|
|
48570
|
-
|
|
48448
|
+
return [4 /*yield*/, next(args)];
|
|
48571
48449
|
case 1:
|
|
48572
|
-
return [2
|
|
48573
|
-
/*return*/
|
|
48574
|
-
, _a.sent()];
|
|
48575
|
-
|
|
48450
|
+
return [2 /*return*/, _a.sent()];
|
|
48576
48451
|
case 2:
|
|
48577
48452
|
err_1 = _a.sent();
|
|
48578
|
-
|
|
48579
48453
|
if (isTimeSkewedError(err_1)) {
|
|
48580
48454
|
serverDate = new Date(err_1.ServerTime);
|
|
48581
48455
|
config.systemClockOffset = serverDate.getTime() - Date.now();
|
|
48582
48456
|
}
|
|
48583
|
-
|
|
48584
48457
|
throw err_1;
|
|
48585
|
-
|
|
48586
48458
|
case 3:
|
|
48587
|
-
return [2
|
|
48588
|
-
/*return*/
|
|
48589
|
-
];
|
|
48459
|
+
return [2 /*return*/];
|
|
48590
48460
|
}
|
|
48591
48461
|
});
|
|
48592
48462
|
});
|
|
48593
48463
|
};
|
|
48594
48464
|
};
|
|
48595
48465
|
};
|
|
48466
|
+
|
|
48596
48467
|
var autoAdjustClockskewMiddlewareOptions = {
|
|
48597
48468
|
step: 'finalizeRequest',
|
|
48598
48469
|
name: 'autoAdjustClockskewMiddleware'
|
|
@@ -48608,44 +48479,30 @@ var credentialsProvider = function credentialsProvider() {
|
|
|
48608
48479
|
switch (_a.label) {
|
|
48609
48480
|
case 0:
|
|
48610
48481
|
_a.trys.push([0, 2,, 3]);
|
|
48611
|
-
|
|
48612
|
-
return [4
|
|
48613
|
-
/*yield*/
|
|
48614
|
-
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
48615
|
-
|
|
48482
|
+
return [4 /*yield*/, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
48616
48483
|
case 1:
|
|
48617
48484
|
credentials = _a.sent();
|
|
48618
|
-
if (!credentials) return [2
|
|
48619
|
-
/*return*/
|
|
48620
|
-
, INVALID_CRED];
|
|
48485
|
+
if (!credentials) return [2 /*return*/, INVALID_CRED];
|
|
48621
48486
|
cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials);
|
|
48622
48487
|
logger.debug('credentials provider get credentials', cred);
|
|
48623
|
-
return [2
|
|
48624
|
-
/*return*/
|
|
48625
|
-
, cred];
|
|
48626
|
-
|
|
48488
|
+
return [2 /*return*/, cred];
|
|
48627
48489
|
case 2:
|
|
48628
48490
|
error_1 = _a.sent();
|
|
48629
48491
|
logger.warn('credentials provider error', error_1);
|
|
48630
|
-
return [2
|
|
48631
|
-
/*return*/
|
|
48632
|
-
, INVALID_CRED];
|
|
48633
|
-
|
|
48492
|
+
return [2 /*return*/, INVALID_CRED];
|
|
48634
48493
|
case 3:
|
|
48635
|
-
return [2
|
|
48636
|
-
/*return*/
|
|
48637
|
-
];
|
|
48494
|
+
return [2 /*return*/];
|
|
48638
48495
|
}
|
|
48639
48496
|
});
|
|
48640
48497
|
});
|
|
48641
48498
|
};
|
|
48499
|
+
|
|
48642
48500
|
var createS3Client = function createS3Client(config, emitter) {
|
|
48643
48501
|
var region = config.region,
|
|
48644
|
-
|
|
48645
|
-
|
|
48646
|
-
|
|
48502
|
+
cancelTokenSource = config.cancelTokenSource,
|
|
48503
|
+
dangerouslyConnectToHttpEndpointForTesting = config.dangerouslyConnectToHttpEndpointForTesting,
|
|
48504
|
+
useAccelerateEndpoint = config.useAccelerateEndpoint;
|
|
48647
48505
|
var localTestingConfig = {};
|
|
48648
|
-
|
|
48649
48506
|
if (dangerouslyConnectToHttpEndpointForTesting) {
|
|
48650
48507
|
localTestingConfig = {
|
|
48651
48508
|
endpoint: _StorageConstants__WEBPACK_IMPORTED_MODULE_3__["localTestingStorageEndpoint"],
|
|
@@ -48654,7 +48511,6 @@ var createS3Client = function createS3Client(config, emitter) {
|
|
|
48654
48511
|
forcePathStyle: true
|
|
48655
48512
|
};
|
|
48656
48513
|
}
|
|
48657
|
-
|
|
48658
48514
|
var s3client = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["S3Client"](__assign(__assign({
|
|
48659
48515
|
region: region,
|
|
48660
48516
|
// Using provider instead of a static credentials, so that if an upload task was in progress, but credentials gets
|
|
@@ -48704,16 +48560,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
48704
48560
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWSS3ProviderMultipartCopierErrors", function() { return AWSS3ProviderMultipartCopierErrors; });
|
|
48705
48561
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWSS3ProviderUploadErrorStrings", function() { return AWSS3ProviderUploadErrorStrings; });
|
|
48706
48562
|
var StorageErrorStrings;
|
|
48707
|
-
|
|
48708
48563
|
(function (StorageErrorStrings) {
|
|
48709
48564
|
StorageErrorStrings["NO_CREDENTIALS"] = "No credentials";
|
|
48710
48565
|
StorageErrorStrings["NO_SRC_KEY"] = "source param should be an object with the property \"key\" with value of type string";
|
|
48711
48566
|
StorageErrorStrings["NO_DEST_KEY"] = "destination param should be an object with the property \"key\" with value of type string";
|
|
48712
48567
|
StorageErrorStrings["INVALID_BLOB"] = "Object must be an instance of Blob";
|
|
48713
48568
|
})(StorageErrorStrings || (StorageErrorStrings = {}));
|
|
48714
|
-
|
|
48715
48569
|
var AWSS3ProviderMultipartCopierErrors;
|
|
48716
|
-
|
|
48717
48570
|
(function (AWSS3ProviderMultipartCopierErrors) {
|
|
48718
48571
|
AWSS3ProviderMultipartCopierErrors["CLEANUP_FAILED"] = "Multipart copy clean up failed";
|
|
48719
48572
|
AWSS3ProviderMultipartCopierErrors["NO_OBJECT_FOUND"] = "Object does not exist";
|
|
@@ -48721,9 +48574,7 @@ var AWSS3ProviderMultipartCopierErrors;
|
|
|
48721
48574
|
AWSS3ProviderMultipartCopierErrors["NO_COPYSOURCE"] = "You must specify a copy source";
|
|
48722
48575
|
AWSS3ProviderMultipartCopierErrors["MAX_NUM_PARTS_EXCEEDED"] = "Only a maximum of 10000 parts are allowed";
|
|
48723
48576
|
})(AWSS3ProviderMultipartCopierErrors || (AWSS3ProviderMultipartCopierErrors = {}));
|
|
48724
|
-
|
|
48725
48577
|
var AWSS3ProviderUploadErrorStrings;
|
|
48726
|
-
|
|
48727
48578
|
(function (AWSS3ProviderUploadErrorStrings) {
|
|
48728
48579
|
AWSS3ProviderUploadErrorStrings["UPLOAD_PAUSED_MESSAGE"] = "paused";
|
|
48729
48580
|
})(AWSS3ProviderUploadErrorStrings || (AWSS3ProviderUploadErrorStrings = {}));
|
|
@@ -48764,11 +48615,9 @@ var dispatchStorageEvent = function dispatchStorageEvent(track, event, attrs, me
|
|
|
48764
48615
|
var data = {
|
|
48765
48616
|
attrs: attrs
|
|
48766
48617
|
};
|
|
48767
|
-
|
|
48768
48618
|
if (metrics) {
|
|
48769
48619
|
data['metrics'] = metrics;
|
|
48770
48620
|
}
|
|
48771
|
-
|
|
48772
48621
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].dispatch('storage', {
|
|
48773
48622
|
event: event,
|
|
48774
48623
|
data: data,
|
|
@@ -48782,7 +48631,6 @@ var isFile = function isFile(x) {
|
|
|
48782
48631
|
var isBlob = function isBlob(x) {
|
|
48783
48632
|
return typeof x !== 'undefined' && x instanceof Blob;
|
|
48784
48633
|
};
|
|
48785
|
-
|
|
48786
48634
|
var isArrayBuffer = function isArrayBuffer(x) {
|
|
48787
48635
|
return typeof x !== 'undefined' && x instanceof ArrayBuffer;
|
|
48788
48636
|
};
|
|
@@ -48823,39 +48671,30 @@ var __assign = undefined && undefined.__assign || function () {
|
|
|
48823
48671
|
__assign = Object.assign || function (t) {
|
|
48824
48672
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
48825
48673
|
s = arguments[i];
|
|
48826
|
-
|
|
48827
48674
|
for (var p in s) {
|
|
48828
48675
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
48829
48676
|
}
|
|
48830
48677
|
}
|
|
48831
|
-
|
|
48832
48678
|
return t;
|
|
48833
48679
|
};
|
|
48834
|
-
|
|
48835
48680
|
return __assign.apply(this, arguments);
|
|
48836
48681
|
};
|
|
48837
48682
|
|
|
48838
48683
|
|
|
48839
|
-
|
|
48840
48684
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('Storage');
|
|
48841
48685
|
var _instance = null;
|
|
48842
|
-
|
|
48843
48686
|
var getInstance = function getInstance() {
|
|
48844
48687
|
if (_instance) {
|
|
48845
48688
|
return _instance;
|
|
48846
48689
|
}
|
|
48847
|
-
|
|
48848
48690
|
logger.debug('Create Storage Instance, debug');
|
|
48849
48691
|
_instance = new _Storage__WEBPACK_IMPORTED_MODULE_0__["Storage"]();
|
|
48850
48692
|
_instance.vault = new _Storage__WEBPACK_IMPORTED_MODULE_0__["Storage"]();
|
|
48851
48693
|
var old_configure = _instance.configure;
|
|
48852
|
-
|
|
48853
48694
|
_instance.configure = function (options) {
|
|
48854
48695
|
logger.debug('storage configure called');
|
|
48855
|
-
|
|
48856
|
-
|
|
48857
|
-
|
|
48858
|
-
|
|
48696
|
+
var vaultConfig = __assign({}, old_configure.call(_instance, options));
|
|
48697
|
+
// set level private for each provider for the vault
|
|
48859
48698
|
Object.keys(vaultConfig).forEach(function (providerName) {
|
|
48860
48699
|
if (typeof vaultConfig[providerName] !== 'string') {
|
|
48861
48700
|
vaultConfig[providerName] = __assign(__assign({}, vaultConfig[providerName]), {
|
|
@@ -48864,19 +48703,15 @@ var getInstance = function getInstance() {
|
|
|
48864
48703
|
}
|
|
48865
48704
|
});
|
|
48866
48705
|
logger.debug('storage vault configure called');
|
|
48867
|
-
|
|
48868
48706
|
_instance.vault.configure(vaultConfig);
|
|
48869
48707
|
};
|
|
48870
|
-
|
|
48871
48708
|
return _instance;
|
|
48872
48709
|
};
|
|
48873
|
-
|
|
48874
48710
|
var Storage = getInstance();
|
|
48875
48711
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(Storage);
|
|
48876
48712
|
/**
|
|
48877
48713
|
* @deprecated use named import
|
|
48878
48714
|
*/
|
|
48879
|
-
|
|
48880
48715
|
/* harmony default export */ __webpack_exports__["default"] = (Storage);
|
|
48881
48716
|
|
|
48882
48717
|
|
|
@@ -48917,30 +48752,24 @@ function _typeof(obj) {
|
|
|
48917
48752
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
48918
48753
|
}, _typeof(obj);
|
|
48919
48754
|
}
|
|
48920
|
-
|
|
48921
48755
|
var __assign = undefined && undefined.__assign || function () {
|
|
48922
48756
|
__assign = Object.assign || function (t) {
|
|
48923
48757
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
48924
48758
|
s = arguments[i];
|
|
48925
|
-
|
|
48926
48759
|
for (var p in s) {
|
|
48927
48760
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
48928
48761
|
}
|
|
48929
48762
|
}
|
|
48930
|
-
|
|
48931
48763
|
return t;
|
|
48932
48764
|
};
|
|
48933
|
-
|
|
48934
48765
|
return __assign.apply(this, arguments);
|
|
48935
48766
|
};
|
|
48936
|
-
|
|
48937
48767
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
48938
48768
|
function adopt(value) {
|
|
48939
48769
|
return value instanceof P ? value : new P(function (resolve) {
|
|
48940
48770
|
resolve(value);
|
|
48941
48771
|
});
|
|
48942
48772
|
}
|
|
48943
|
-
|
|
48944
48773
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48945
48774
|
function fulfilled(value) {
|
|
48946
48775
|
try {
|
|
@@ -48949,7 +48778,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
48949
48778
|
reject(e);
|
|
48950
48779
|
}
|
|
48951
48780
|
}
|
|
48952
|
-
|
|
48953
48781
|
function rejected(value) {
|
|
48954
48782
|
try {
|
|
48955
48783
|
step(generator["throw"](value));
|
|
@@ -48957,29 +48785,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
48957
48785
|
reject(e);
|
|
48958
48786
|
}
|
|
48959
48787
|
}
|
|
48960
|
-
|
|
48961
48788
|
function step(result) {
|
|
48962
48789
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
48963
48790
|
}
|
|
48964
|
-
|
|
48965
48791
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48966
48792
|
});
|
|
48967
48793
|
};
|
|
48968
|
-
|
|
48969
48794
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
48970
48795
|
var _ = {
|
|
48971
|
-
|
|
48972
|
-
|
|
48973
|
-
|
|
48974
|
-
|
|
48796
|
+
label: 0,
|
|
48797
|
+
sent: function sent() {
|
|
48798
|
+
if (t[0] & 1) throw t[1];
|
|
48799
|
+
return t[1];
|
|
48800
|
+
},
|
|
48801
|
+
trys: [],
|
|
48802
|
+
ops: []
|
|
48975
48803
|
},
|
|
48976
|
-
|
|
48977
|
-
|
|
48978
|
-
|
|
48979
|
-
|
|
48980
|
-
y,
|
|
48981
|
-
t,
|
|
48982
|
-
g;
|
|
48804
|
+
f,
|
|
48805
|
+
y,
|
|
48806
|
+
t,
|
|
48807
|
+
g;
|
|
48983
48808
|
return g = {
|
|
48984
48809
|
next: verb(0),
|
|
48985
48810
|
"throw": verb(1),
|
|
@@ -48987,79 +48812,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
48987
48812
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
48988
48813
|
return this;
|
|
48989
48814
|
}), g;
|
|
48990
|
-
|
|
48991
48815
|
function verb(n) {
|
|
48992
48816
|
return function (v) {
|
|
48993
48817
|
return step([n, v]);
|
|
48994
48818
|
};
|
|
48995
48819
|
}
|
|
48996
|
-
|
|
48997
48820
|
function step(op) {
|
|
48998
48821
|
if (f) throw new TypeError("Generator is already executing.");
|
|
48999
|
-
|
|
49000
48822
|
while (_) {
|
|
49001
48823
|
try {
|
|
49002
48824
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49003
48825
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
49004
|
-
|
|
49005
48826
|
switch (op[0]) {
|
|
49006
48827
|
case 0:
|
|
49007
48828
|
case 1:
|
|
49008
48829
|
t = op;
|
|
49009
48830
|
break;
|
|
49010
|
-
|
|
49011
48831
|
case 4:
|
|
49012
48832
|
_.label++;
|
|
49013
48833
|
return {
|
|
49014
48834
|
value: op[1],
|
|
49015
48835
|
done: false
|
|
49016
48836
|
};
|
|
49017
|
-
|
|
49018
48837
|
case 5:
|
|
49019
48838
|
_.label++;
|
|
49020
48839
|
y = op[1];
|
|
49021
48840
|
op = [0];
|
|
49022
48841
|
continue;
|
|
49023
|
-
|
|
49024
48842
|
case 7:
|
|
49025
48843
|
op = _.ops.pop();
|
|
49026
|
-
|
|
49027
48844
|
_.trys.pop();
|
|
49028
|
-
|
|
49029
48845
|
continue;
|
|
49030
|
-
|
|
49031
48846
|
default:
|
|
49032
48847
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
49033
48848
|
_ = 0;
|
|
49034
48849
|
continue;
|
|
49035
48850
|
}
|
|
49036
|
-
|
|
49037
48851
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
49038
48852
|
_.label = op[1];
|
|
49039
48853
|
break;
|
|
49040
48854
|
}
|
|
49041
|
-
|
|
49042
48855
|
if (op[0] === 6 && _.label < t[1]) {
|
|
49043
48856
|
_.label = t[1];
|
|
49044
48857
|
t = op;
|
|
49045
48858
|
break;
|
|
49046
48859
|
}
|
|
49047
|
-
|
|
49048
48860
|
if (t && _.label < t[2]) {
|
|
49049
48861
|
_.label = t[2];
|
|
49050
|
-
|
|
49051
48862
|
_.ops.push(op);
|
|
49052
|
-
|
|
49053
48863
|
break;
|
|
49054
48864
|
}
|
|
49055
|
-
|
|
49056
48865
|
if (t[2]) _.ops.pop();
|
|
49057
|
-
|
|
49058
48866
|
_.trys.pop();
|
|
49059
|
-
|
|
49060
48867
|
continue;
|
|
49061
48868
|
}
|
|
49062
|
-
|
|
49063
48869
|
op = body.call(thisArg, _);
|
|
49064
48870
|
} catch (e) {
|
|
49065
48871
|
op = [6, e];
|
|
@@ -49068,7 +48874,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
49068
48874
|
f = t = 0;
|
|
49069
48875
|
}
|
|
49070
48876
|
}
|
|
49071
|
-
|
|
49072
48877
|
if (op[0] & 5) throw op[1];
|
|
49073
48878
|
return {
|
|
49074
48879
|
value: op[0] ? op[1] : void 0,
|
|
@@ -49076,15 +48881,13 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
49076
48881
|
};
|
|
49077
48882
|
}
|
|
49078
48883
|
};
|
|
49079
|
-
|
|
49080
48884
|
var __read = undefined && undefined.__read || function (o, n) {
|
|
49081
48885
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49082
48886
|
if (!m) return o;
|
|
49083
48887
|
var i = m.call(o),
|
|
49084
|
-
|
|
49085
|
-
|
|
49086
|
-
|
|
49087
|
-
|
|
48888
|
+
r,
|
|
48889
|
+
ar = [],
|
|
48890
|
+
e;
|
|
49088
48891
|
try {
|
|
49089
48892
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
49090
48893
|
ar.push(r.value);
|
|
@@ -49100,15 +48903,12 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
49100
48903
|
if (e) throw e.error;
|
|
49101
48904
|
}
|
|
49102
48905
|
}
|
|
49103
|
-
|
|
49104
48906
|
return ar;
|
|
49105
48907
|
};
|
|
49106
|
-
|
|
49107
48908
|
var __spread = undefined && undefined.__spread || function () {
|
|
49108
48909
|
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
49109
48910
|
ar = ar.concat(__read(arguments[i]));
|
|
49110
48911
|
}
|
|
49111
|
-
|
|
49112
48912
|
return ar;
|
|
49113
48913
|
};
|
|
49114
48914
|
/*
|
|
@@ -49136,30 +48936,23 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
49136
48936
|
|
|
49137
48937
|
|
|
49138
48938
|
|
|
49139
|
-
|
|
49140
|
-
|
|
49141
48939
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AWSS3Provider');
|
|
49142
48940
|
var DEFAULT_STORAGE_LEVEL = 'public';
|
|
49143
48941
|
var DEFAULT_PRESIGN_EXPIRATION = 900;
|
|
49144
48942
|
/**
|
|
49145
48943
|
* Provide storage methods to use AWS S3
|
|
49146
48944
|
*/
|
|
49147
|
-
|
|
49148
|
-
var AWSS3Provider =
|
|
49149
|
-
/** @class */
|
|
49150
|
-
function () {
|
|
48945
|
+
var AWSS3Provider = /** @class */function () {
|
|
49151
48946
|
/**
|
|
49152
48947
|
* Initialize Storage with AWS configurations
|
|
49153
48948
|
* @param {Object} config - Configuration object for storage
|
|
49154
48949
|
*/
|
|
49155
48950
|
function AWSS3Provider(config) {
|
|
49156
48951
|
var _this = this;
|
|
49157
|
-
|
|
49158
48952
|
this._config = config ? config : {};
|
|
49159
48953
|
this._storage = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["StorageHelper"]().getStorage();
|
|
49160
48954
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].listen('auth', function (data) {
|
|
49161
48955
|
var payload = data.payload;
|
|
49162
|
-
|
|
49163
48956
|
if (payload.event === 'signOut' || payload.event === 'signIn') {
|
|
49164
48957
|
_this._storage.removeItem(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_11__["UPLOADS_STORAGE_KEY"]);
|
|
49165
48958
|
}
|
|
@@ -49169,16 +48962,12 @@ function () {
|
|
|
49169
48962
|
/**
|
|
49170
48963
|
* get the category of the plugin
|
|
49171
48964
|
*/
|
|
49172
|
-
|
|
49173
|
-
|
|
49174
48965
|
AWSS3Provider.prototype.getCategory = function () {
|
|
49175
48966
|
return AWSS3Provider.CATEGORY;
|
|
49176
48967
|
};
|
|
49177
48968
|
/**
|
|
49178
48969
|
* get provider name of the plugin
|
|
49179
48970
|
*/
|
|
49180
|
-
|
|
49181
|
-
|
|
49182
48971
|
AWSS3Provider.prototype.getProviderName = function () {
|
|
49183
48972
|
return AWSS3Provider.PROVIDER_NAME;
|
|
49184
48973
|
};
|
|
@@ -49187,37 +48976,30 @@ function () {
|
|
|
49187
48976
|
* @param {Object} config - Configuration of the Storage
|
|
49188
48977
|
* @return {Object} - Current configuration
|
|
49189
48978
|
*/
|
|
49190
|
-
|
|
49191
|
-
|
|
49192
48979
|
AWSS3Provider.prototype.configure = function (config) {
|
|
49193
48980
|
logger.debug('configure Storage', config);
|
|
49194
48981
|
if (!config) return this._config;
|
|
49195
48982
|
var amplifyConfig = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Parser"].parseMobilehubConfig(config);
|
|
49196
48983
|
this._config = Object.assign({}, this._config, amplifyConfig.Storage);
|
|
49197
|
-
|
|
49198
48984
|
if (!this._config.bucket) {
|
|
49199
48985
|
logger.debug('Do not have bucket yet');
|
|
49200
48986
|
}
|
|
49201
|
-
|
|
49202
48987
|
return this._config;
|
|
49203
48988
|
};
|
|
49204
|
-
|
|
49205
48989
|
AWSS3Provider.prototype.startResumableUpload = function (addTaskInput, config) {
|
|
49206
48990
|
var s3Client = addTaskInput.s3Client,
|
|
49207
|
-
|
|
49208
|
-
|
|
49209
|
-
|
|
49210
|
-
|
|
48991
|
+
emitter = addTaskInput.emitter,
|
|
48992
|
+
key = addTaskInput.key,
|
|
48993
|
+
file = addTaskInput.file,
|
|
48994
|
+
params = addTaskInput.params;
|
|
49211
48995
|
var progressCallback = config.progressCallback,
|
|
49212
|
-
|
|
49213
|
-
|
|
49214
|
-
|
|
49215
|
-
|
|
49216
|
-
|
|
48996
|
+
completeCallback = config.completeCallback,
|
|
48997
|
+
errorCallback = config.errorCallback,
|
|
48998
|
+
_a = config.track,
|
|
48999
|
+
track = _a === void 0 ? false : _a;
|
|
49217
49000
|
if (!(file instanceof Blob)) {
|
|
49218
49001
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].INVALID_BLOB);
|
|
49219
49002
|
}
|
|
49220
|
-
|
|
49221
49003
|
emitter.on(_AWSS3UploadTask__WEBPACK_IMPORTED_MODULE_10__["TaskEvents"].UPLOAD_PROGRESS, function (event) {
|
|
49222
49004
|
if (progressCallback) {
|
|
49223
49005
|
if (typeof progressCallback === 'function') {
|
|
@@ -49244,9 +49026,9 @@ function () {
|
|
|
49244
49026
|
logger.warn('errorCallback should be a function, not a ' + _typeof(errorCallback));
|
|
49245
49027
|
}
|
|
49246
49028
|
}
|
|
49247
|
-
});
|
|
49029
|
+
});
|
|
49030
|
+
// we want to keep this function sync so we defer this promise to AWSS3UploadTask to resolve when it's needed
|
|
49248
49031
|
// when its doing a final check with _listSingleFile function
|
|
49249
|
-
|
|
49250
49032
|
var prefixPromise = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get().then(function (credentials) {
|
|
49251
49033
|
var cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials);
|
|
49252
49034
|
return Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["getPrefix"])(__assign(__assign({}, config), {
|
|
@@ -49265,8 +49047,8 @@ function () {
|
|
|
49265
49047
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'upload', {
|
|
49266
49048
|
method: 'put',
|
|
49267
49049
|
result: 'success'
|
|
49268
|
-
}, null, "Upload Task created successfully for " + key);
|
|
49269
|
-
|
|
49050
|
+
}, null, "Upload Task created successfully for " + key);
|
|
49051
|
+
// automatically start the upload task
|
|
49270
49052
|
task.resume();
|
|
49271
49053
|
return task;
|
|
49272
49054
|
};
|
|
@@ -49280,43 +49062,31 @@ function () {
|
|
|
49280
49062
|
* @param {S3ProviderCopyConfig} [config] - Optional configuration for s3 commands.
|
|
49281
49063
|
* @return {Promise<S3ProviderCopyOutput>} The key of the copied object.
|
|
49282
49064
|
*/
|
|
49283
|
-
|
|
49284
|
-
|
|
49285
49065
|
AWSS3Provider.prototype.copy = function (src, dest, config) {
|
|
49286
49066
|
return __awaiter(this, void 0, void 0, function () {
|
|
49287
49067
|
var credentialsOK, opt, acl, bucket, cacheControl, expires, track, serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, _a, srcLevel, srcIdentityId, srcKey, _b, destLevel, destKey, srcPrefix, destPrefix, finalSrcKey, finalDestKey, params, s3, error_1;
|
|
49288
|
-
|
|
49289
49068
|
return __generator(this, function (_c) {
|
|
49290
49069
|
switch (_c.label) {
|
|
49291
49070
|
case 0:
|
|
49292
|
-
return [4
|
|
49293
|
-
/*yield*/
|
|
49294
|
-
, this._ensureCredentials()];
|
|
49295
|
-
|
|
49071
|
+
return [4 /*yield*/, this._ensureCredentials()];
|
|
49296
49072
|
case 1:
|
|
49297
49073
|
credentialsOK = _c.sent();
|
|
49298
|
-
|
|
49299
49074
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
49300
49075
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_CREDENTIALS);
|
|
49301
49076
|
}
|
|
49302
|
-
|
|
49303
49077
|
opt = Object.assign({}, this._config, config);
|
|
49304
49078
|
acl = opt.acl, bucket = opt.bucket, cacheControl = opt.cacheControl, expires = opt.expires, track = opt.track, serverSideEncryption = opt.serverSideEncryption, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, SSEKMSKeyId = opt.SSEKMSKeyId;
|
|
49305
49079
|
_a = src.level, srcLevel = _a === void 0 ? DEFAULT_STORAGE_LEVEL : _a, srcIdentityId = src.identityId, srcKey = src.key;
|
|
49306
49080
|
_b = dest.level, destLevel = _b === void 0 ? DEFAULT_STORAGE_LEVEL : _b, destKey = dest.key;
|
|
49307
|
-
|
|
49308
49081
|
if (!srcKey || typeof srcKey !== 'string') {
|
|
49309
49082
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_SRC_KEY);
|
|
49310
49083
|
}
|
|
49311
|
-
|
|
49312
49084
|
if (!destKey || typeof destKey !== 'string') {
|
|
49313
49085
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_DEST_KEY);
|
|
49314
49086
|
}
|
|
49315
|
-
|
|
49316
49087
|
if (srcLevel !== 'protected' && srcIdentityId) {
|
|
49317
49088
|
logger.warn("You may copy files from another user if the source level is \"protected\", currently it's " + srcLevel);
|
|
49318
49089
|
}
|
|
49319
|
-
|
|
49320
49090
|
srcPrefix = this._prefix(__assign(__assign(__assign({}, opt), {
|
|
49321
49091
|
level: srcLevel
|
|
49322
49092
|
}), srcIdentityId && {
|
|
@@ -49337,51 +49107,36 @@ function () {
|
|
|
49337
49107
|
};
|
|
49338
49108
|
if (cacheControl) params.CacheControl = cacheControl;
|
|
49339
49109
|
if (expires) params.Expires = expires;
|
|
49340
|
-
|
|
49341
49110
|
if (serverSideEncryption) {
|
|
49342
49111
|
params.ServerSideEncryption = serverSideEncryption;
|
|
49343
49112
|
}
|
|
49344
|
-
|
|
49345
49113
|
if (SSECustomerAlgorithm) {
|
|
49346
49114
|
params.SSECustomerAlgorithm = SSECustomerAlgorithm;
|
|
49347
49115
|
}
|
|
49348
|
-
|
|
49349
49116
|
if (SSECustomerKey) {
|
|
49350
49117
|
params.SSECustomerKey = SSECustomerKey;
|
|
49351
49118
|
}
|
|
49352
|
-
|
|
49353
49119
|
if (SSECustomerKeyMD5) {
|
|
49354
49120
|
params.SSECustomerKeyMD5 = SSECustomerKeyMD5;
|
|
49355
49121
|
}
|
|
49356
|
-
|
|
49357
49122
|
if (SSEKMSKeyId) {
|
|
49358
49123
|
params.SSEKMSKeyId = SSEKMSKeyId;
|
|
49359
49124
|
}
|
|
49360
|
-
|
|
49361
49125
|
if (acl) params.ACL = acl;
|
|
49362
49126
|
s3 = this._createNewS3Client(opt);
|
|
49363
49127
|
_c.label = 2;
|
|
49364
|
-
|
|
49365
49128
|
case 2:
|
|
49366
49129
|
_c.trys.push([2, 4,, 5]);
|
|
49367
|
-
|
|
49368
|
-
return [4
|
|
49369
|
-
/*yield*/
|
|
49370
|
-
, s3.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["CopyObjectCommand"](params))];
|
|
49371
|
-
|
|
49130
|
+
return [4 /*yield*/, s3.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["CopyObjectCommand"](params))];
|
|
49372
49131
|
case 3:
|
|
49373
49132
|
_c.sent();
|
|
49374
|
-
|
|
49375
49133
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'copy', {
|
|
49376
49134
|
method: 'copy',
|
|
49377
49135
|
result: 'success'
|
|
49378
49136
|
}, null, "Copy success from " + srcKey + " to " + destKey);
|
|
49379
|
-
return [2
|
|
49380
|
-
/*return*/
|
|
49381
|
-
, {
|
|
49137
|
+
return [2 /*return*/, {
|
|
49382
49138
|
key: destKey
|
|
49383
49139
|
}];
|
|
49384
|
-
|
|
49385
49140
|
case 4:
|
|
49386
49141
|
error_1 = _c.sent();
|
|
49387
49142
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'copy', {
|
|
@@ -49389,11 +49144,8 @@ function () {
|
|
|
49389
49144
|
result: 'failed'
|
|
49390
49145
|
}, null, "Copy failed from " + srcKey + " to " + destKey);
|
|
49391
49146
|
throw error_1;
|
|
49392
|
-
|
|
49393
49147
|
case 5:
|
|
49394
|
-
return [2
|
|
49395
|
-
/*return*/
|
|
49396
|
-
];
|
|
49148
|
+
return [2 /*return*/];
|
|
49397
49149
|
}
|
|
49398
49150
|
});
|
|
49399
49151
|
});
|
|
@@ -49402,21 +49154,15 @@ function () {
|
|
|
49402
49154
|
AWSS3Provider.prototype.get = function (key, config) {
|
|
49403
49155
|
return __awaiter(this, void 0, void 0, function () {
|
|
49404
49156
|
var credentialsOK, opt, bucket, download, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, expires, track, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, progressCallback, prefix, final_key, emitter, s3, params, getObjectCommand, response, error_2, signer, request, url, _a, error_3;
|
|
49405
|
-
|
|
49406
49157
|
return __generator(this, function (_b) {
|
|
49407
49158
|
switch (_b.label) {
|
|
49408
49159
|
case 0:
|
|
49409
|
-
return [4
|
|
49410
|
-
/*yield*/
|
|
49411
|
-
, this._ensureCredentials()];
|
|
49412
|
-
|
|
49160
|
+
return [4 /*yield*/, this._ensureCredentials()];
|
|
49413
49161
|
case 1:
|
|
49414
49162
|
credentialsOK = _b.sent();
|
|
49415
|
-
|
|
49416
49163
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
49417
49164
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_CREDENTIALS);
|
|
49418
49165
|
}
|
|
49419
|
-
|
|
49420
49166
|
opt = Object.assign({}, this._config, config);
|
|
49421
49167
|
bucket = opt.bucket, download = opt.download, cacheControl = opt.cacheControl, contentDisposition = opt.contentDisposition, contentEncoding = opt.contentEncoding, contentLanguage = opt.contentLanguage, contentType = opt.contentType, expires = opt.expires, track = opt.track, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, progressCallback = opt.progressCallback;
|
|
49422
49168
|
prefix = this._prefix(opt);
|
|
@@ -49427,35 +49173,27 @@ function () {
|
|
|
49427
49173
|
params = {
|
|
49428
49174
|
Bucket: bucket,
|
|
49429
49175
|
Key: final_key
|
|
49430
|
-
};
|
|
49431
|
-
|
|
49176
|
+
};
|
|
49177
|
+
// See: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getObject-property
|
|
49432
49178
|
if (cacheControl) params.ResponseCacheControl = cacheControl;
|
|
49433
49179
|
if (contentDisposition) params.ResponseContentDisposition = contentDisposition;
|
|
49434
49180
|
if (contentEncoding) params.ResponseContentEncoding = contentEncoding;
|
|
49435
49181
|
if (contentLanguage) params.ResponseContentLanguage = contentLanguage;
|
|
49436
49182
|
if (contentType) params.ResponseContentType = contentType;
|
|
49437
|
-
|
|
49438
49183
|
if (SSECustomerAlgorithm) {
|
|
49439
49184
|
params.SSECustomerAlgorithm = SSECustomerAlgorithm;
|
|
49440
49185
|
}
|
|
49441
|
-
|
|
49442
49186
|
if (SSECustomerKey) {
|
|
49443
49187
|
params.SSECustomerKey = SSECustomerKey;
|
|
49444
49188
|
}
|
|
49445
|
-
|
|
49446
49189
|
if (SSECustomerKeyMD5) {
|
|
49447
49190
|
params.SSECustomerKeyMD5 = SSECustomerKeyMD5;
|
|
49448
49191
|
}
|
|
49449
|
-
|
|
49450
|
-
if (!(download === true)) return [3
|
|
49451
|
-
/*break*/
|
|
49452
|
-
, 5];
|
|
49192
|
+
if (!(download === true)) return [3 /*break*/, 5];
|
|
49453
49193
|
getObjectCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["GetObjectCommand"](params);
|
|
49454
49194
|
_b.label = 2;
|
|
49455
|
-
|
|
49456
49195
|
case 2:
|
|
49457
49196
|
_b.trys.push([2, 4,, 5]);
|
|
49458
|
-
|
|
49459
49197
|
if (progressCallback) {
|
|
49460
49198
|
if (typeof progressCallback === 'function') {
|
|
49461
49199
|
emitter.on(_axios_http_handler__WEBPACK_IMPORTED_MODULE_5__["SEND_DOWNLOAD_PROGRESS_EVENT"], function (progress) {
|
|
@@ -49465,11 +49203,7 @@ function () {
|
|
|
49465
49203
|
logger.warn('progressCallback should be a function, not a ' + _typeof(progressCallback));
|
|
49466
49204
|
}
|
|
49467
49205
|
}
|
|
49468
|
-
|
|
49469
|
-
return [4
|
|
49470
|
-
/*yield*/
|
|
49471
|
-
, s3.send(getObjectCommand)];
|
|
49472
|
-
|
|
49206
|
+
return [4 /*yield*/, s3.send(getObjectCommand)];
|
|
49473
49207
|
case 3:
|
|
49474
49208
|
response = _b.sent();
|
|
49475
49209
|
emitter.removeAllListeners(_axios_http_handler__WEBPACK_IMPORTED_MODULE_5__["SEND_DOWNLOAD_PROGRESS_EVENT"]);
|
|
@@ -49479,10 +49213,7 @@ function () {
|
|
|
49479
49213
|
}, {
|
|
49480
49214
|
fileSize: Number(response.Body['size'] || response.Body['length'])
|
|
49481
49215
|
}, "Download success for " + key);
|
|
49482
|
-
return [2
|
|
49483
|
-
/*return*/
|
|
49484
|
-
, response];
|
|
49485
|
-
|
|
49216
|
+
return [2 /*return*/, response];
|
|
49486
49217
|
case 4:
|
|
49487
49218
|
error_2 = _b.sent();
|
|
49488
49219
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'download', {
|
|
@@ -49490,34 +49221,23 @@ function () {
|
|
|
49490
49221
|
result: 'failed'
|
|
49491
49222
|
}, null, "Download failed with " + error_2.message);
|
|
49492
49223
|
throw error_2;
|
|
49493
|
-
|
|
49494
49224
|
case 5:
|
|
49495
49225
|
_b.trys.push([5, 8,, 9]);
|
|
49496
|
-
|
|
49497
49226
|
signer = new _aws_sdk_s3_request_presigner__WEBPACK_IMPORTED_MODULE_4__["S3RequestPresigner"](__assign({}, s3.config));
|
|
49498
|
-
return [4
|
|
49499
|
-
/*yield*/
|
|
49500
|
-
, Object(_aws_sdk_util_create_request__WEBPACK_IMPORTED_MODULE_3__["createRequest"])(s3, new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["GetObjectCommand"](params))];
|
|
49501
|
-
|
|
49227
|
+
return [4 /*yield*/, Object(_aws_sdk_util_create_request__WEBPACK_IMPORTED_MODULE_3__["createRequest"])(s3, new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["GetObjectCommand"](params))];
|
|
49502
49228
|
case 6:
|
|
49503
49229
|
request = _b.sent();
|
|
49504
49230
|
_a = _aws_sdk_util_format_url__WEBPACK_IMPORTED_MODULE_2__["formatUrl"];
|
|
49505
|
-
return [4
|
|
49506
|
-
/*yield*/
|
|
49507
|
-
, signer.presign(request, {
|
|
49231
|
+
return [4 /*yield*/, signer.presign(request, {
|
|
49508
49232
|
expiresIn: expires || DEFAULT_PRESIGN_EXPIRATION
|
|
49509
49233
|
})];
|
|
49510
|
-
|
|
49511
49234
|
case 7:
|
|
49512
49235
|
url = _a.apply(void 0, [_b.sent()]);
|
|
49513
49236
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'getSignedUrl', {
|
|
49514
49237
|
method: 'get',
|
|
49515
49238
|
result: 'success'
|
|
49516
49239
|
}, null, "Signed URL: " + url);
|
|
49517
|
-
return [2
|
|
49518
|
-
/*return*/
|
|
49519
|
-
, url];
|
|
49520
|
-
|
|
49240
|
+
return [2 /*return*/, url];
|
|
49521
49241
|
case 8:
|
|
49522
49242
|
error_3 = _b.sent();
|
|
49523
49243
|
logger.warn('get signed url error', error_3);
|
|
@@ -49526,11 +49246,8 @@ function () {
|
|
|
49526
49246
|
result: 'failed'
|
|
49527
49247
|
}, null, "Could not get a signed URL for " + key);
|
|
49528
49248
|
throw error_3;
|
|
49529
|
-
|
|
49530
49249
|
case 9:
|
|
49531
|
-
return [2
|
|
49532
|
-
/*return*/
|
|
49533
|
-
];
|
|
49250
|
+
return [2 /*return*/];
|
|
49534
49251
|
}
|
|
49535
49252
|
});
|
|
49536
49253
|
});
|
|
@@ -49543,28 +49260,26 @@ function () {
|
|
|
49543
49260
|
* @return an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on
|
|
49544
49261
|
* success.
|
|
49545
49262
|
*/
|
|
49546
|
-
|
|
49547
|
-
|
|
49548
49263
|
AWSS3Provider.prototype.put = function (key, object, config) {
|
|
49549
49264
|
var opt = Object.assign({}, this._config, config);
|
|
49550
49265
|
var bucket = opt.bucket,
|
|
49551
|
-
|
|
49552
|
-
|
|
49553
|
-
|
|
49554
|
-
|
|
49266
|
+
track = opt.track,
|
|
49267
|
+
progressCallback = opt.progressCallback,
|
|
49268
|
+
level = opt.level,
|
|
49269
|
+
resumable = opt.resumable;
|
|
49555
49270
|
var contentType = opt.contentType,
|
|
49556
|
-
|
|
49557
|
-
|
|
49558
|
-
|
|
49559
|
-
|
|
49560
|
-
|
|
49561
|
-
|
|
49562
|
-
|
|
49271
|
+
contentDisposition = opt.contentDisposition,
|
|
49272
|
+
contentEncoding = opt.contentEncoding,
|
|
49273
|
+
cacheControl = opt.cacheControl,
|
|
49274
|
+
expires = opt.expires,
|
|
49275
|
+
metadata = opt.metadata,
|
|
49276
|
+
tagging = opt.tagging,
|
|
49277
|
+
acl = opt.acl;
|
|
49563
49278
|
var serverSideEncryption = opt.serverSideEncryption,
|
|
49564
|
-
|
|
49565
|
-
|
|
49566
|
-
|
|
49567
|
-
|
|
49279
|
+
SSECustomerAlgorithm = opt.SSECustomerAlgorithm,
|
|
49280
|
+
SSECustomerKey = opt.SSECustomerKey,
|
|
49281
|
+
SSECustomerKeyMD5 = opt.SSECustomerKeyMD5,
|
|
49282
|
+
SSEKMSKeyId = opt.SSEKMSKeyId;
|
|
49568
49283
|
var type = contentType ? contentType : 'binary/octet-stream';
|
|
49569
49284
|
var params = {
|
|
49570
49285
|
Bucket: bucket,
|
|
@@ -49572,63 +49287,48 @@ function () {
|
|
|
49572
49287
|
Body: object,
|
|
49573
49288
|
ContentType: type
|
|
49574
49289
|
};
|
|
49575
|
-
|
|
49576
49290
|
if (cacheControl) {
|
|
49577
49291
|
params.CacheControl = cacheControl;
|
|
49578
49292
|
}
|
|
49579
|
-
|
|
49580
49293
|
if (contentDisposition) {
|
|
49581
49294
|
params.ContentDisposition = contentDisposition;
|
|
49582
49295
|
}
|
|
49583
|
-
|
|
49584
49296
|
if (contentEncoding) {
|
|
49585
49297
|
params.ContentEncoding = contentEncoding;
|
|
49586
49298
|
}
|
|
49587
|
-
|
|
49588
49299
|
if (expires) {
|
|
49589
49300
|
params.Expires = expires;
|
|
49590
49301
|
}
|
|
49591
|
-
|
|
49592
49302
|
if (metadata) {
|
|
49593
49303
|
params.Metadata = metadata;
|
|
49594
49304
|
}
|
|
49595
|
-
|
|
49596
49305
|
if (tagging) {
|
|
49597
49306
|
params.Tagging = tagging;
|
|
49598
49307
|
}
|
|
49599
|
-
|
|
49600
49308
|
if (serverSideEncryption) {
|
|
49601
49309
|
params.ServerSideEncryption = serverSideEncryption;
|
|
49602
49310
|
}
|
|
49603
|
-
|
|
49604
49311
|
if (SSECustomerAlgorithm) {
|
|
49605
49312
|
params.SSECustomerAlgorithm = SSECustomerAlgorithm;
|
|
49606
49313
|
}
|
|
49607
|
-
|
|
49608
49314
|
if (SSECustomerKey) {
|
|
49609
49315
|
params.SSECustomerKey = SSECustomerKey;
|
|
49610
49316
|
}
|
|
49611
|
-
|
|
49612
49317
|
if (SSECustomerKeyMD5) {
|
|
49613
49318
|
params.SSECustomerKeyMD5 = SSECustomerKeyMD5;
|
|
49614
49319
|
}
|
|
49615
|
-
|
|
49616
49320
|
if (SSEKMSKeyId) {
|
|
49617
49321
|
params.SSEKMSKeyId = SSEKMSKeyId;
|
|
49618
49322
|
}
|
|
49619
|
-
|
|
49620
49323
|
var emitter = new events__WEBPACK_IMPORTED_MODULE_12__["EventEmitter"]();
|
|
49621
49324
|
var uploader = new _AWSS3ProviderManagedUpload__WEBPACK_IMPORTED_MODULE_9__["AWSS3ProviderManagedUpload"](params, opt, emitter);
|
|
49622
|
-
|
|
49623
49325
|
if (acl) {
|
|
49624
49326
|
params.ACL = acl;
|
|
49625
49327
|
}
|
|
49626
|
-
|
|
49627
49328
|
if (resumable === true) {
|
|
49628
|
-
var s3Client = this._createNewS3Client(opt);
|
|
49329
|
+
var s3Client = this._createNewS3Client(opt);
|
|
49330
|
+
// we are using aws sdk middleware to inject the prefix to key, this way we don't have to call
|
|
49629
49331
|
// this._ensureCredentials() which allows us to make this function sync so we can return non-Promise like UploadTask
|
|
49630
|
-
|
|
49631
|
-
|
|
49632
49332
|
s3Client.middlewareStack.add(Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["createPrefixMiddleware"])(opt, key), _common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["prefixMiddlewareOptions"]);
|
|
49633
49333
|
var addTaskInput = {
|
|
49634
49334
|
bucket: bucket,
|
|
@@ -49638,11 +49338,10 @@ function () {
|
|
|
49638
49338
|
emitter: emitter,
|
|
49639
49339
|
accessLevel: level,
|
|
49640
49340
|
params: params
|
|
49641
|
-
};
|
|
49642
|
-
|
|
49341
|
+
};
|
|
49342
|
+
// explicitly asserting the type here as Typescript could not infer that resumable is of type true
|
|
49643
49343
|
return this.startResumableUpload(addTaskInput, config);
|
|
49644
49344
|
}
|
|
49645
|
-
|
|
49646
49345
|
try {
|
|
49647
49346
|
if (progressCallback) {
|
|
49648
49347
|
if (typeof progressCallback === 'function') {
|
|
@@ -49653,7 +49352,6 @@ function () {
|
|
|
49653
49352
|
logger.warn('progressCallback should be a function, not a ' + _typeof(progressCallback));
|
|
49654
49353
|
}
|
|
49655
49354
|
}
|
|
49656
|
-
|
|
49657
49355
|
return uploader.upload().then(function (response) {
|
|
49658
49356
|
logger.debug('upload result', response);
|
|
49659
49357
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'upload', {
|
|
@@ -49679,25 +49377,18 @@ function () {
|
|
|
49679
49377
|
* @param {S3ProviderRemoveConfig} [config] - Optional configuration for the underlying S3 command
|
|
49680
49378
|
* @return {Promise<S3ProviderRemoveOutput>} - Promise resolves upon successful removal of the object
|
|
49681
49379
|
*/
|
|
49682
|
-
|
|
49683
|
-
|
|
49684
49380
|
AWSS3Provider.prototype.remove = function (key, config) {
|
|
49685
49381
|
return __awaiter(this, void 0, void 0, function () {
|
|
49686
49382
|
var credentialsOK, opt, bucket, track, prefix, final_key, s3, params, deleteObjectCommand, response, error_4;
|
|
49687
49383
|
return __generator(this, function (_a) {
|
|
49688
49384
|
switch (_a.label) {
|
|
49689
49385
|
case 0:
|
|
49690
|
-
return [4
|
|
49691
|
-
/*yield*/
|
|
49692
|
-
, this._ensureCredentials()];
|
|
49693
|
-
|
|
49386
|
+
return [4 /*yield*/, this._ensureCredentials()];
|
|
49694
49387
|
case 1:
|
|
49695
49388
|
credentialsOK = _a.sent();
|
|
49696
|
-
|
|
49697
49389
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
49698
49390
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_CREDENTIALS);
|
|
49699
49391
|
}
|
|
49700
|
-
|
|
49701
49392
|
opt = Object.assign({}, this._config, config);
|
|
49702
49393
|
bucket = opt.bucket, track = opt.track;
|
|
49703
49394
|
prefix = this._prefix(opt);
|
|
@@ -49710,24 +49401,16 @@ function () {
|
|
|
49710
49401
|
};
|
|
49711
49402
|
deleteObjectCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["DeleteObjectCommand"](params);
|
|
49712
49403
|
_a.label = 2;
|
|
49713
|
-
|
|
49714
49404
|
case 2:
|
|
49715
49405
|
_a.trys.push([2, 4,, 5]);
|
|
49716
|
-
|
|
49717
|
-
return [4
|
|
49718
|
-
/*yield*/
|
|
49719
|
-
, s3.send(deleteObjectCommand)];
|
|
49720
|
-
|
|
49406
|
+
return [4 /*yield*/, s3.send(deleteObjectCommand)];
|
|
49721
49407
|
case 3:
|
|
49722
49408
|
response = _a.sent();
|
|
49723
49409
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'delete', {
|
|
49724
49410
|
method: 'remove',
|
|
49725
49411
|
result: 'success'
|
|
49726
49412
|
}, null, "Deleted " + key + " successfully");
|
|
49727
|
-
return [2
|
|
49728
|
-
/*return*/
|
|
49729
|
-
, response];
|
|
49730
|
-
|
|
49413
|
+
return [2 /*return*/, response];
|
|
49731
49414
|
case 4:
|
|
49732
49415
|
error_4 = _a.sent();
|
|
49733
49416
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'delete', {
|
|
@@ -49735,11 +49418,8 @@ function () {
|
|
|
49735
49418
|
result: 'failed'
|
|
49736
49419
|
}, null, "Deletion of " + key + " failed with " + error_4);
|
|
49737
49420
|
throw error_4;
|
|
49738
|
-
|
|
49739
49421
|
case 5:
|
|
49740
|
-
return [2
|
|
49741
|
-
/*return*/
|
|
49742
|
-
];
|
|
49422
|
+
return [2 /*return*/];
|
|
49743
49423
|
}
|
|
49744
49424
|
});
|
|
49745
49425
|
});
|
|
@@ -49757,13 +49437,9 @@ function () {
|
|
|
49757
49437
|
};
|
|
49758
49438
|
s3 = this._createNewS3Client(opt);
|
|
49759
49439
|
listObjectsV2Command = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["ListObjectsV2Command"](__assign({}, params));
|
|
49760
|
-
return [4
|
|
49761
|
-
/*yield*/
|
|
49762
|
-
, s3.send(listObjectsV2Command)];
|
|
49763
|
-
|
|
49440
|
+
return [4 /*yield*/, s3.send(listObjectsV2Command)];
|
|
49764
49441
|
case 1:
|
|
49765
49442
|
response = _a.sent();
|
|
49766
|
-
|
|
49767
49443
|
if (response && response.Contents) {
|
|
49768
49444
|
result.contents = response.Contents.map(function (item) {
|
|
49769
49445
|
return {
|
|
@@ -49775,10 +49451,7 @@ function () {
|
|
|
49775
49451
|
});
|
|
49776
49452
|
result.nextToken = response.NextContinuationToken;
|
|
49777
49453
|
}
|
|
49778
|
-
|
|
49779
|
-
return [2
|
|
49780
|
-
/*return*/
|
|
49781
|
-
, result];
|
|
49454
|
+
return [2 /*return*/, result];
|
|
49782
49455
|
}
|
|
49783
49456
|
});
|
|
49784
49457
|
});
|
|
@@ -49790,35 +49463,26 @@ function () {
|
|
|
49790
49463
|
* @return {Promise<S3ProviderListOutput>} - Promise resolves to list of keys, eTags, lastModified and file size for
|
|
49791
49464
|
* all objects in path
|
|
49792
49465
|
*/
|
|
49793
|
-
|
|
49794
|
-
|
|
49795
49466
|
AWSS3Provider.prototype.list = function (path, config) {
|
|
49796
49467
|
return __awaiter(this, void 0, void 0, function () {
|
|
49797
49468
|
var credentialsOK, opt, bucket, track, maxKeys, prefix, final_path, list, token, listResult, params, error_5;
|
|
49798
49469
|
return __generator(this, function (_a) {
|
|
49799
49470
|
switch (_a.label) {
|
|
49800
49471
|
case 0:
|
|
49801
|
-
return [4
|
|
49802
|
-
/*yield*/
|
|
49803
|
-
, this._ensureCredentials()];
|
|
49804
|
-
|
|
49472
|
+
return [4 /*yield*/, this._ensureCredentials()];
|
|
49805
49473
|
case 1:
|
|
49806
49474
|
credentialsOK = _a.sent();
|
|
49807
|
-
|
|
49808
49475
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
49809
49476
|
throw new Error(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_6__["StorageErrorStrings"].NO_CREDENTIALS);
|
|
49810
49477
|
}
|
|
49811
|
-
|
|
49812
49478
|
opt = Object.assign({}, this._config, config);
|
|
49813
49479
|
bucket = opt.bucket, track = opt.track, maxKeys = opt.maxKeys;
|
|
49814
49480
|
prefix = this._prefix(opt);
|
|
49815
49481
|
final_path = prefix + path;
|
|
49816
49482
|
logger.debug('list ' + path + ' from ' + final_path);
|
|
49817
49483
|
_a.label = 2;
|
|
49818
|
-
|
|
49819
49484
|
case 2:
|
|
49820
49485
|
_a.trys.push([2, 10,, 11]);
|
|
49821
|
-
|
|
49822
49486
|
list = [];
|
|
49823
49487
|
token = void 0;
|
|
49824
49488
|
listResult = void 0;
|
|
@@ -49827,57 +49491,37 @@ function () {
|
|
|
49827
49491
|
Prefix: final_path,
|
|
49828
49492
|
MaxKeys: 1000
|
|
49829
49493
|
};
|
|
49830
|
-
if (!(maxKeys === 'ALL')) return [3
|
|
49831
|
-
/*break*/
|
|
49832
|
-
, 7];
|
|
49494
|
+
if (!(maxKeys === 'ALL')) return [3 /*break*/, 7];
|
|
49833
49495
|
_a.label = 3;
|
|
49834
|
-
|
|
49835
49496
|
case 3:
|
|
49836
49497
|
params.ContinuationToken = token;
|
|
49837
49498
|
params.MaxKeys = 1000;
|
|
49838
|
-
return [4
|
|
49839
|
-
/*yield*/
|
|
49840
|
-
, this._list(params, opt, prefix)];
|
|
49841
|
-
|
|
49499
|
+
return [4 /*yield*/, this._list(params, opt, prefix)];
|
|
49842
49500
|
case 4:
|
|
49843
49501
|
listResult = _a.sent();
|
|
49844
49502
|
list.push.apply(list, __spread(listResult.contents));
|
|
49845
49503
|
if (listResult.nextToken) token = listResult.nextToken;
|
|
49846
49504
|
_a.label = 5;
|
|
49847
|
-
|
|
49848
49505
|
case 5:
|
|
49849
|
-
if (listResult.nextToken) return [3
|
|
49850
|
-
/*break*/
|
|
49851
|
-
, 3];
|
|
49506
|
+
if (listResult.nextToken) return [3 /*break*/, 3];
|
|
49852
49507
|
_a.label = 6;
|
|
49853
|
-
|
|
49854
49508
|
case 6:
|
|
49855
|
-
return [3
|
|
49856
|
-
/*break*/
|
|
49857
|
-
, 9];
|
|
49858
|
-
|
|
49509
|
+
return [3 /*break*/, 9];
|
|
49859
49510
|
case 7:
|
|
49860
49511
|
maxKeys < 1000 || typeof maxKeys === 'string' ? params.MaxKeys = maxKeys : params.MaxKeys = 1000;
|
|
49861
|
-
return [4
|
|
49862
|
-
/*yield*/
|
|
49863
|
-
, this._list(params, opt, prefix)];
|
|
49864
|
-
|
|
49512
|
+
return [4 /*yield*/, this._list(params, opt, prefix)];
|
|
49865
49513
|
case 8:
|
|
49866
49514
|
listResult = _a.sent();
|
|
49867
49515
|
list.push.apply(list, __spread(listResult.contents));
|
|
49868
49516
|
if (maxKeys > 1000) logger.warn("maxkeys can be from 0 - 1000 or 'ALL'. To list all files you can set maxKeys to 'ALL'.");
|
|
49869
49517
|
_a.label = 9;
|
|
49870
|
-
|
|
49871
49518
|
case 9:
|
|
49872
49519
|
Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_7__["dispatchStorageEvent"])(track, 'list', {
|
|
49873
49520
|
method: 'list',
|
|
49874
49521
|
result: 'success'
|
|
49875
49522
|
}, null, list.length + " items returned from list operation");
|
|
49876
49523
|
logger.debug('list', list);
|
|
49877
|
-
return [2
|
|
49878
|
-
/*return*/
|
|
49879
|
-
, list];
|
|
49880
|
-
|
|
49524
|
+
return [2 /*return*/, list];
|
|
49881
49525
|
case 10:
|
|
49882
49526
|
error_5 = _a.sent();
|
|
49883
49527
|
logger.warn('list error', error_5);
|
|
@@ -49886,11 +49530,8 @@ function () {
|
|
|
49886
49530
|
result: 'failed'
|
|
49887
49531
|
}, null, "Listing items failed: " + error_5.message);
|
|
49888
49532
|
throw error_5;
|
|
49889
|
-
|
|
49890
49533
|
case 11:
|
|
49891
|
-
return [2
|
|
49892
|
-
/*return*/
|
|
49893
|
-
];
|
|
49534
|
+
return [2 /*return*/];
|
|
49894
49535
|
}
|
|
49895
49536
|
});
|
|
49896
49537
|
});
|
|
@@ -49903,34 +49544,20 @@ function () {
|
|
|
49903
49544
|
switch (_a.label) {
|
|
49904
49545
|
case 0:
|
|
49905
49546
|
_a.trys.push([0, 2,, 3]);
|
|
49906
|
-
|
|
49907
|
-
return [4
|
|
49908
|
-
/*yield*/
|
|
49909
|
-
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
49910
|
-
|
|
49547
|
+
return [4 /*yield*/, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
49911
49548
|
case 1:
|
|
49912
49549
|
credentials = _a.sent();
|
|
49913
|
-
if (!credentials) return [2
|
|
49914
|
-
/*return*/
|
|
49915
|
-
, false];
|
|
49550
|
+
if (!credentials) return [2 /*return*/, false];
|
|
49916
49551
|
cred = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials);
|
|
49917
49552
|
logger.debug('set credentials for storage', cred);
|
|
49918
49553
|
this._config.credentials = cred;
|
|
49919
|
-
return [2
|
|
49920
|
-
/*return*/
|
|
49921
|
-
, true];
|
|
49922
|
-
|
|
49554
|
+
return [2 /*return*/, true];
|
|
49923
49555
|
case 2:
|
|
49924
49556
|
error_6 = _a.sent();
|
|
49925
49557
|
logger.warn('ensure credentials error', error_6);
|
|
49926
|
-
return [2
|
|
49927
|
-
/*return*/
|
|
49928
|
-
, false];
|
|
49929
|
-
|
|
49558
|
+
return [2 /*return*/, false];
|
|
49930
49559
|
case 3:
|
|
49931
|
-
return [2
|
|
49932
|
-
/*return*/
|
|
49933
|
-
];
|
|
49560
|
+
return [2 /*return*/];
|
|
49934
49561
|
}
|
|
49935
49562
|
});
|
|
49936
49563
|
});
|
|
@@ -49939,23 +49566,19 @@ function () {
|
|
|
49939
49566
|
AWSS3Provider.prototype._isWithCredentials = function (config) {
|
|
49940
49567
|
return _typeof(config) === 'object' && config.hasOwnProperty('credentials');
|
|
49941
49568
|
};
|
|
49942
|
-
|
|
49943
49569
|
AWSS3Provider.prototype._prefix = function (config) {
|
|
49944
49570
|
var credentials = config.credentials,
|
|
49945
|
-
|
|
49571
|
+
level = config.level;
|
|
49946
49572
|
var customPrefix = config.customPrefix || {};
|
|
49947
49573
|
var identityId = config.identityId || credentials.identityId;
|
|
49948
49574
|
var privatePath = (customPrefix["private"] !== undefined ? customPrefix["private"] : 'private/') + identityId + '/';
|
|
49949
49575
|
var protectedPath = (customPrefix["protected"] !== undefined ? customPrefix["protected"] : 'protected/') + identityId + '/';
|
|
49950
49576
|
var publicPath = customPrefix["public"] !== undefined ? customPrefix["public"] : 'public/';
|
|
49951
|
-
|
|
49952
49577
|
switch (level) {
|
|
49953
49578
|
case 'private':
|
|
49954
49579
|
return privatePath;
|
|
49955
|
-
|
|
49956
49580
|
case 'protected':
|
|
49957
49581
|
return protectedPath;
|
|
49958
|
-
|
|
49959
49582
|
default:
|
|
49960
49583
|
return publicPath;
|
|
49961
49584
|
}
|
|
@@ -49963,24 +49586,19 @@ function () {
|
|
|
49963
49586
|
/**
|
|
49964
49587
|
* Creates an S3 client with new V3 aws sdk
|
|
49965
49588
|
*/
|
|
49966
|
-
|
|
49967
|
-
|
|
49968
49589
|
AWSS3Provider.prototype._createNewS3Client = function (config, emitter) {
|
|
49969
49590
|
var s3client = Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["createS3Client"])(config, emitter);
|
|
49970
49591
|
s3client.middlewareStack.add(Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["autoAdjustClockskewMiddleware"])(s3client.config), _common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_8__["autoAdjustClockskewMiddlewareOptions"]);
|
|
49971
49592
|
return s3client;
|
|
49972
49593
|
};
|
|
49973
|
-
|
|
49974
49594
|
AWSS3Provider.CATEGORY = 'Storage';
|
|
49975
49595
|
AWSS3Provider.PROVIDER_NAME = 'AWSS3';
|
|
49976
49596
|
return AWSS3Provider;
|
|
49977
49597
|
}();
|
|
49978
49598
|
|
|
49979
|
-
|
|
49980
49599
|
/**
|
|
49981
49600
|
* @deprecated use named import
|
|
49982
49601
|
*/
|
|
49983
|
-
|
|
49984
49602
|
/* harmony default export */ __webpack_exports__["default"] = (AWSS3Provider);
|
|
49985
49603
|
|
|
49986
49604
|
/***/ }),
|
|
@@ -50023,31 +49641,24 @@ function _typeof(obj) {
|
|
|
50023
49641
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
50024
49642
|
* and limitations under the License.
|
|
50025
49643
|
*/
|
|
50026
|
-
|
|
50027
|
-
|
|
50028
49644
|
var __assign = undefined && undefined.__assign || function () {
|
|
50029
49645
|
__assign = Object.assign || function (t) {
|
|
50030
49646
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
50031
49647
|
s = arguments[i];
|
|
50032
|
-
|
|
50033
49648
|
for (var p in s) {
|
|
50034
49649
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
50035
49650
|
}
|
|
50036
49651
|
}
|
|
50037
|
-
|
|
50038
49652
|
return t;
|
|
50039
49653
|
};
|
|
50040
|
-
|
|
50041
49654
|
return __assign.apply(this, arguments);
|
|
50042
49655
|
};
|
|
50043
|
-
|
|
50044
49656
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
50045
49657
|
function adopt(value) {
|
|
50046
49658
|
return value instanceof P ? value : new P(function (resolve) {
|
|
50047
49659
|
resolve(value);
|
|
50048
49660
|
});
|
|
50049
49661
|
}
|
|
50050
|
-
|
|
50051
49662
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50052
49663
|
function fulfilled(value) {
|
|
50053
49664
|
try {
|
|
@@ -50056,7 +49667,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
50056
49667
|
reject(e);
|
|
50057
49668
|
}
|
|
50058
49669
|
}
|
|
50059
|
-
|
|
50060
49670
|
function rejected(value) {
|
|
50061
49671
|
try {
|
|
50062
49672
|
step(generator["throw"](value));
|
|
@@ -50064,29 +49674,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
50064
49674
|
reject(e);
|
|
50065
49675
|
}
|
|
50066
49676
|
}
|
|
50067
|
-
|
|
50068
49677
|
function step(result) {
|
|
50069
49678
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
50070
49679
|
}
|
|
50071
|
-
|
|
50072
49680
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50073
49681
|
});
|
|
50074
49682
|
};
|
|
50075
|
-
|
|
50076
49683
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
50077
49684
|
var _ = {
|
|
50078
|
-
|
|
50079
|
-
|
|
50080
|
-
|
|
50081
|
-
|
|
49685
|
+
label: 0,
|
|
49686
|
+
sent: function sent() {
|
|
49687
|
+
if (t[0] & 1) throw t[1];
|
|
49688
|
+
return t[1];
|
|
49689
|
+
},
|
|
49690
|
+
trys: [],
|
|
49691
|
+
ops: []
|
|
50082
49692
|
},
|
|
50083
|
-
|
|
50084
|
-
|
|
50085
|
-
|
|
50086
|
-
|
|
50087
|
-
y,
|
|
50088
|
-
t,
|
|
50089
|
-
g;
|
|
49693
|
+
f,
|
|
49694
|
+
y,
|
|
49695
|
+
t,
|
|
49696
|
+
g;
|
|
50090
49697
|
return g = {
|
|
50091
49698
|
next: verb(0),
|
|
50092
49699
|
"throw": verb(1),
|
|
@@ -50094,79 +49701,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50094
49701
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
50095
49702
|
return this;
|
|
50096
49703
|
}), g;
|
|
50097
|
-
|
|
50098
49704
|
function verb(n) {
|
|
50099
49705
|
return function (v) {
|
|
50100
49706
|
return step([n, v]);
|
|
50101
49707
|
};
|
|
50102
49708
|
}
|
|
50103
|
-
|
|
50104
49709
|
function step(op) {
|
|
50105
49710
|
if (f) throw new TypeError("Generator is already executing.");
|
|
50106
|
-
|
|
50107
49711
|
while (_) {
|
|
50108
49712
|
try {
|
|
50109
49713
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50110
49714
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50111
|
-
|
|
50112
49715
|
switch (op[0]) {
|
|
50113
49716
|
case 0:
|
|
50114
49717
|
case 1:
|
|
50115
49718
|
t = op;
|
|
50116
49719
|
break;
|
|
50117
|
-
|
|
50118
49720
|
case 4:
|
|
50119
49721
|
_.label++;
|
|
50120
49722
|
return {
|
|
50121
49723
|
value: op[1],
|
|
50122
49724
|
done: false
|
|
50123
49725
|
};
|
|
50124
|
-
|
|
50125
49726
|
case 5:
|
|
50126
49727
|
_.label++;
|
|
50127
49728
|
y = op[1];
|
|
50128
49729
|
op = [0];
|
|
50129
49730
|
continue;
|
|
50130
|
-
|
|
50131
49731
|
case 7:
|
|
50132
49732
|
op = _.ops.pop();
|
|
50133
|
-
|
|
50134
49733
|
_.trys.pop();
|
|
50135
|
-
|
|
50136
49734
|
continue;
|
|
50137
|
-
|
|
50138
49735
|
default:
|
|
50139
49736
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
50140
49737
|
_ = 0;
|
|
50141
49738
|
continue;
|
|
50142
49739
|
}
|
|
50143
|
-
|
|
50144
49740
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
50145
49741
|
_.label = op[1];
|
|
50146
49742
|
break;
|
|
50147
49743
|
}
|
|
50148
|
-
|
|
50149
49744
|
if (op[0] === 6 && _.label < t[1]) {
|
|
50150
49745
|
_.label = t[1];
|
|
50151
49746
|
t = op;
|
|
50152
49747
|
break;
|
|
50153
49748
|
}
|
|
50154
|
-
|
|
50155
49749
|
if (t && _.label < t[2]) {
|
|
50156
49750
|
_.label = t[2];
|
|
50157
|
-
|
|
50158
49751
|
_.ops.push(op);
|
|
50159
|
-
|
|
50160
49752
|
break;
|
|
50161
49753
|
}
|
|
50162
|
-
|
|
50163
49754
|
if (t[2]) _.ops.pop();
|
|
50164
|
-
|
|
50165
49755
|
_.trys.pop();
|
|
50166
|
-
|
|
50167
49756
|
continue;
|
|
50168
49757
|
}
|
|
50169
|
-
|
|
50170
49758
|
op = body.call(thisArg, _);
|
|
50171
49759
|
} catch (e) {
|
|
50172
49760
|
op = [6, e];
|
|
@@ -50175,7 +49763,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50175
49763
|
f = t = 0;
|
|
50176
49764
|
}
|
|
50177
49765
|
}
|
|
50178
|
-
|
|
50179
49766
|
if (op[0] & 5) throw op[1];
|
|
50180
49767
|
return {
|
|
50181
49768
|
value: op[0] ? op[1] : void 0,
|
|
@@ -50188,24 +49775,19 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50188
49775
|
|
|
50189
49776
|
|
|
50190
49777
|
|
|
50191
|
-
|
|
50192
49778
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AWSS3ProviderManagedUpload');
|
|
50193
|
-
|
|
50194
|
-
var AWSS3ProviderManagedUpload =
|
|
50195
|
-
/** @class */
|
|
50196
|
-
function () {
|
|
49779
|
+
var AWSS3ProviderManagedUpload = /** @class */function () {
|
|
50197
49780
|
function AWSS3ProviderManagedUpload(params, opts, emitter) {
|
|
50198
49781
|
// Defaults
|
|
50199
49782
|
this.minPartSize = 5 * 1024 * 1024; // in MB
|
|
50200
|
-
|
|
50201
|
-
|
|
50202
|
-
|
|
49783
|
+
this.queueSize = 4;
|
|
49784
|
+
// Data for current upload
|
|
50203
49785
|
this.body = null;
|
|
50204
49786
|
this.params = null;
|
|
50205
49787
|
this.opts = null;
|
|
50206
49788
|
this.completedParts = [];
|
|
50207
|
-
this.uploadId = null;
|
|
50208
|
-
|
|
49789
|
+
this.uploadId = null;
|
|
49790
|
+
// Progress reporting
|
|
50209
49791
|
this.bytesUploaded = 0;
|
|
50210
49792
|
this.totalBytesToUpload = 0;
|
|
50211
49793
|
this.emitter = null;
|
|
@@ -50214,43 +49796,28 @@ function () {
|
|
|
50214
49796
|
this.emitter = emitter;
|
|
50215
49797
|
this.s3client = this._createNewS3Client(opts, emitter);
|
|
50216
49798
|
}
|
|
50217
|
-
|
|
50218
49799
|
AWSS3ProviderManagedUpload.prototype.upload = function () {
|
|
50219
49800
|
return __awaiter(this, void 0, void 0, function () {
|
|
50220
49801
|
var _a, putObjectCommand, _b, numberOfPartsToUpload, parts, start, error_1;
|
|
50221
|
-
|
|
50222
49802
|
var _this = this;
|
|
50223
|
-
|
|
50224
49803
|
return __generator(this, function (_c) {
|
|
50225
49804
|
switch (_c.label) {
|
|
50226
49805
|
case 0:
|
|
50227
49806
|
_c.trys.push([0, 10,, 12]);
|
|
50228
|
-
|
|
50229
49807
|
_a = this;
|
|
50230
|
-
return [4
|
|
50231
|
-
/*yield*/
|
|
50232
|
-
, this.validateAndSanitizeBody(this.params.Body)];
|
|
50233
|
-
|
|
49808
|
+
return [4 /*yield*/, this.validateAndSanitizeBody(this.params.Body)];
|
|
50234
49809
|
case 1:
|
|
50235
49810
|
_a.body = _c.sent();
|
|
50236
49811
|
this.totalBytesToUpload = this.byteLength(this.body);
|
|
50237
|
-
if (!(this.totalBytesToUpload <= this.minPartSize)) return [3
|
|
50238
|
-
|
|
50239
|
-
, 2]; // Multipart upload is not required. Upload the sanitized body as is
|
|
50240
|
-
|
|
49812
|
+
if (!(this.totalBytesToUpload <= this.minPartSize)) return [3 /*break*/, 2];
|
|
49813
|
+
// Multipart upload is not required. Upload the sanitized body as is
|
|
50241
49814
|
this.params.Body = this.body;
|
|
50242
49815
|
putObjectCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["PutObjectCommand"](this.params);
|
|
50243
|
-
return [2
|
|
50244
|
-
/*return*/
|
|
50245
|
-
, this.s3client.send(putObjectCommand)];
|
|
50246
|
-
|
|
49816
|
+
return [2 /*return*/, this.s3client.send(putObjectCommand)];
|
|
50247
49817
|
case 2:
|
|
50248
49818
|
// Step 1: Initiate the multi part upload
|
|
50249
49819
|
_b = this;
|
|
50250
|
-
return [4
|
|
50251
|
-
/*yield*/
|
|
50252
|
-
, this.createMultiPartUpload()];
|
|
50253
|
-
|
|
49820
|
+
return [4 /*yield*/, this.createMultiPartUpload()];
|
|
50254
49821
|
case 3:
|
|
50255
49822
|
// Step 1: Initiate the multi part upload
|
|
50256
49823
|
_b.uploadId = _c.sent();
|
|
@@ -50258,65 +49825,38 @@ function () {
|
|
|
50258
49825
|
parts = this.createParts();
|
|
50259
49826
|
start = 0;
|
|
50260
49827
|
_c.label = 4;
|
|
50261
|
-
|
|
50262
49828
|
case 4:
|
|
50263
|
-
if (!(start < numberOfPartsToUpload)) return [3
|
|
50264
|
-
|
|
50265
|
-
|
|
50266
|
-
|
|
50267
|
-
return [4
|
|
50268
|
-
/*yield*/
|
|
50269
|
-
, this.uploadParts(this.uploadId, parts.slice(start, start + this.queueSize))];
|
|
50270
|
-
|
|
49829
|
+
if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 7];
|
|
49830
|
+
// Upload as many as `queueSize` parts simultaneously
|
|
49831
|
+
return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + this.queueSize))];
|
|
50271
49832
|
case 5:
|
|
50272
49833
|
// Upload as many as `queueSize` parts simultaneously
|
|
50273
49834
|
_c.sent();
|
|
50274
|
-
|
|
50275
49835
|
_c.label = 6;
|
|
50276
|
-
|
|
50277
49836
|
case 6:
|
|
50278
49837
|
start += this.queueSize;
|
|
50279
|
-
return [3
|
|
50280
|
-
/*break*/
|
|
50281
|
-
, 4];
|
|
50282
|
-
|
|
49838
|
+
return [3 /*break*/, 4];
|
|
50283
49839
|
case 7:
|
|
50284
49840
|
parts.map(function (part) {
|
|
50285
49841
|
_this.removeEventListener(part);
|
|
50286
49842
|
});
|
|
50287
|
-
return [4
|
|
50288
|
-
/*yield*/
|
|
50289
|
-
, this.finishMultiPartUpload(this.uploadId)];
|
|
50290
|
-
|
|
49843
|
+
return [4 /*yield*/, this.finishMultiPartUpload(this.uploadId)];
|
|
50291
49844
|
case 8:
|
|
50292
49845
|
// Step 3: Finalize the upload such that S3 can recreate the file
|
|
50293
|
-
return [2
|
|
50294
|
-
/*return*/
|
|
50295
|
-
, _c.sent()];
|
|
50296
|
-
|
|
49846
|
+
return [2 /*return*/, _c.sent()];
|
|
50297
49847
|
case 9:
|
|
50298
|
-
return [3
|
|
50299
|
-
/*break*/
|
|
50300
|
-
, 12];
|
|
50301
|
-
|
|
49848
|
+
return [3 /*break*/, 12];
|
|
50302
49849
|
case 10:
|
|
50303
|
-
error_1 = _c.sent();
|
|
50304
|
-
|
|
50305
|
-
return [4
|
|
50306
|
-
/*yield*/
|
|
50307
|
-
, this.cleanup(this.uploadId)];
|
|
50308
|
-
|
|
49850
|
+
error_1 = _c.sent();
|
|
49851
|
+
// if any error is thrown, call cleanup
|
|
49852
|
+
return [4 /*yield*/, this.cleanup(this.uploadId)];
|
|
50309
49853
|
case 11:
|
|
50310
49854
|
// if any error is thrown, call cleanup
|
|
50311
49855
|
_c.sent();
|
|
50312
|
-
|
|
50313
49856
|
logger.error('Error. Cancelling the multipart upload.');
|
|
50314
49857
|
throw error_1;
|
|
50315
|
-
|
|
50316
49858
|
case 12:
|
|
50317
|
-
return [2
|
|
50318
|
-
/*return*/
|
|
50319
|
-
];
|
|
49859
|
+
return [2 /*return*/];
|
|
50320
49860
|
}
|
|
50321
49861
|
});
|
|
50322
49862
|
});
|
|
@@ -50325,7 +49865,6 @@ function () {
|
|
|
50325
49865
|
AWSS3ProviderManagedUpload.prototype.createParts = function () {
|
|
50326
49866
|
try {
|
|
50327
49867
|
var parts = [];
|
|
50328
|
-
|
|
50329
49868
|
for (var bodyStart = 0; bodyStart < this.totalBytesToUpload;) {
|
|
50330
49869
|
var bodyEnd = Math.min(bodyStart + this.minPartSize, this.totalBytesToUpload);
|
|
50331
49870
|
parts.push({
|
|
@@ -50336,14 +49875,12 @@ function () {
|
|
|
50336
49875
|
});
|
|
50337
49876
|
bodyStart += this.minPartSize;
|
|
50338
49877
|
}
|
|
50339
|
-
|
|
50340
49878
|
return parts;
|
|
50341
49879
|
} catch (error) {
|
|
50342
49880
|
logger.error(error);
|
|
50343
49881
|
throw error;
|
|
50344
49882
|
}
|
|
50345
49883
|
};
|
|
50346
|
-
|
|
50347
49884
|
AWSS3ProviderManagedUpload.prototype.createMultiPartUpload = function () {
|
|
50348
49885
|
return __awaiter(this, void 0, void 0, function () {
|
|
50349
49886
|
var createMultiPartUploadCommand, response, error_2;
|
|
@@ -50351,28 +49888,18 @@ function () {
|
|
|
50351
49888
|
switch (_a.label) {
|
|
50352
49889
|
case 0:
|
|
50353
49890
|
_a.trys.push([0, 2,, 3]);
|
|
50354
|
-
|
|
50355
49891
|
createMultiPartUploadCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["CreateMultipartUploadCommand"](this.params);
|
|
50356
|
-
return [4
|
|
50357
|
-
/*yield*/
|
|
50358
|
-
, this.s3client.send(createMultiPartUploadCommand)];
|
|
50359
|
-
|
|
49892
|
+
return [4 /*yield*/, this.s3client.send(createMultiPartUploadCommand)];
|
|
50360
49893
|
case 1:
|
|
50361
49894
|
response = _a.sent();
|
|
50362
49895
|
logger.debug(response.UploadId);
|
|
50363
|
-
return [2
|
|
50364
|
-
/*return*/
|
|
50365
|
-
, response.UploadId];
|
|
50366
|
-
|
|
49896
|
+
return [2 /*return*/, response.UploadId];
|
|
50367
49897
|
case 2:
|
|
50368
49898
|
error_2 = _a.sent();
|
|
50369
49899
|
logger.error(error_2);
|
|
50370
49900
|
throw error_2;
|
|
50371
|
-
|
|
50372
49901
|
case 3:
|
|
50373
|
-
return [2
|
|
50374
|
-
/*return*/
|
|
50375
|
-
];
|
|
49902
|
+
return [2 /*return*/];
|
|
50376
49903
|
}
|
|
50377
49904
|
});
|
|
50378
49905
|
});
|
|
@@ -50381,25 +49908,17 @@ function () {
|
|
|
50381
49908
|
* @private Not to be extended outside of tests
|
|
50382
49909
|
* @VisibleFotTesting
|
|
50383
49910
|
*/
|
|
50384
|
-
|
|
50385
|
-
|
|
50386
49911
|
AWSS3ProviderManagedUpload.prototype.uploadParts = function (uploadId, parts) {
|
|
50387
49912
|
return __awaiter(this, void 0, void 0, function () {
|
|
50388
49913
|
var allResults, i, error_3;
|
|
50389
|
-
|
|
50390
49914
|
var _this = this;
|
|
50391
|
-
|
|
50392
49915
|
return __generator(this, function (_a) {
|
|
50393
49916
|
switch (_a.label) {
|
|
50394
49917
|
case 0:
|
|
50395
49918
|
_a.trys.push([0, 2,, 3]);
|
|
50396
|
-
|
|
50397
|
-
return [4
|
|
50398
|
-
/*yield*/
|
|
50399
|
-
, Promise.all(parts.map(function (part) {
|
|
49919
|
+
return [4 /*yield*/, Promise.all(parts.map(function (part) {
|
|
50400
49920
|
return __awaiter(_this, void 0, void 0, function () {
|
|
50401
49921
|
var options, _a, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, res;
|
|
50402
|
-
|
|
50403
49922
|
return __generator(this, function (_b) {
|
|
50404
49923
|
switch (_b.label) {
|
|
50405
49924
|
case 0:
|
|
@@ -50408,9 +49927,7 @@ function () {
|
|
|
50408
49927
|
emitter: part.emitter
|
|
50409
49928
|
};
|
|
50410
49929
|
_a = this.params, Key = _a.Key, Bucket = _a.Bucket, SSECustomerAlgorithm = _a.SSECustomerAlgorithm, SSECustomerKey = _a.SSECustomerKey, SSECustomerKeyMD5 = _a.SSECustomerKeyMD5;
|
|
50411
|
-
return [4
|
|
50412
|
-
/*yield*/
|
|
50413
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["UploadPartCommand"](__assign(__assign(__assign({
|
|
49930
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["UploadPartCommand"](__assign(__assign(__assign({
|
|
50414
49931
|
PartNumber: part.partNumber,
|
|
50415
49932
|
Body: part.bodyPart,
|
|
50416
49933
|
UploadId: uploadId,
|
|
@@ -50423,40 +49940,29 @@ function () {
|
|
|
50423
49940
|
}), SSECustomerKeyMD5 && {
|
|
50424
49941
|
SSECustomerKeyMD5: SSECustomerKeyMD5
|
|
50425
49942
|
})), options)];
|
|
50426
|
-
|
|
50427
49943
|
case 1:
|
|
50428
49944
|
res = _b.sent();
|
|
50429
|
-
return [2
|
|
50430
|
-
/*return*/
|
|
50431
|
-
, res];
|
|
49945
|
+
return [2 /*return*/, res];
|
|
50432
49946
|
}
|
|
50433
49947
|
});
|
|
50434
49948
|
});
|
|
50435
49949
|
}))];
|
|
50436
|
-
|
|
50437
49950
|
case 1:
|
|
50438
|
-
allResults = _a.sent();
|
|
50439
|
-
|
|
49951
|
+
allResults = _a.sent();
|
|
49952
|
+
// The order of resolved promises is the same as input promise order.
|
|
50440
49953
|
for (i = 0; i < allResults.length; i++) {
|
|
50441
49954
|
this.completedParts.push({
|
|
50442
49955
|
PartNumber: parts[i].partNumber,
|
|
50443
49956
|
ETag: allResults[i].ETag
|
|
50444
49957
|
});
|
|
50445
49958
|
}
|
|
50446
|
-
|
|
50447
|
-
return [3
|
|
50448
|
-
/*break*/
|
|
50449
|
-
, 3];
|
|
50450
|
-
|
|
49959
|
+
return [3 /*break*/, 3];
|
|
50451
49960
|
case 2:
|
|
50452
49961
|
error_3 = _a.sent();
|
|
50453
49962
|
logger.error('Error happened while uploading a part. Cancelling the multipart upload');
|
|
50454
49963
|
throw error_3;
|
|
50455
|
-
|
|
50456
49964
|
case 3:
|
|
50457
|
-
return [2
|
|
50458
|
-
/*return*/
|
|
50459
|
-
];
|
|
49965
|
+
return [2 /*return*/];
|
|
50460
49966
|
}
|
|
50461
49967
|
});
|
|
50462
49968
|
});
|
|
@@ -50478,29 +49984,18 @@ function () {
|
|
|
50478
49984
|
};
|
|
50479
49985
|
completeUploadCommand = new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["CompleteMultipartUploadCommand"](input);
|
|
50480
49986
|
_a.label = 1;
|
|
50481
|
-
|
|
50482
49987
|
case 1:
|
|
50483
49988
|
_a.trys.push([1, 3,, 4]);
|
|
50484
|
-
|
|
50485
|
-
return [4
|
|
50486
|
-
/*yield*/
|
|
50487
|
-
, this.s3client.send(completeUploadCommand)];
|
|
50488
|
-
|
|
49989
|
+
return [4 /*yield*/, this.s3client.send(completeUploadCommand)];
|
|
50489
49990
|
case 2:
|
|
50490
49991
|
data = _a.sent();
|
|
50491
|
-
return [2
|
|
50492
|
-
/*return*/
|
|
50493
|
-
, data.Key];
|
|
50494
|
-
|
|
49992
|
+
return [2 /*return*/, data.Key];
|
|
50495
49993
|
case 3:
|
|
50496
49994
|
error_4 = _a.sent();
|
|
50497
49995
|
logger.error('Error happened while finishing the upload.');
|
|
50498
49996
|
throw error_4;
|
|
50499
|
-
|
|
50500
49997
|
case 4:
|
|
50501
|
-
return [2
|
|
50502
|
-
/*return*/
|
|
50503
|
-
];
|
|
49998
|
+
return [2 /*return*/];
|
|
50504
49999
|
}
|
|
50505
50000
|
});
|
|
50506
50001
|
});
|
|
@@ -50522,27 +50017,16 @@ function () {
|
|
|
50522
50017
|
Key: this.params.Key,
|
|
50523
50018
|
UploadId: uploadId
|
|
50524
50019
|
};
|
|
50525
|
-
return [4
|
|
50526
|
-
/*yield*/
|
|
50527
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["AbortMultipartUploadCommand"](input))];
|
|
50528
|
-
|
|
50020
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["AbortMultipartUploadCommand"](input))];
|
|
50529
50021
|
case 1:
|
|
50530
50022
|
_a.sent();
|
|
50531
|
-
|
|
50532
|
-
return [4
|
|
50533
|
-
/*yield*/
|
|
50534
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["ListPartsCommand"](input))];
|
|
50535
|
-
|
|
50023
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_1__["ListPartsCommand"](input))];
|
|
50536
50024
|
case 2:
|
|
50537
50025
|
data = _a.sent();
|
|
50538
|
-
|
|
50539
50026
|
if (data && data.Parts && data.Parts.length > 0) {
|
|
50540
50027
|
throw new Error('Multipart upload clean up failed.');
|
|
50541
50028
|
}
|
|
50542
|
-
|
|
50543
|
-
return [2
|
|
50544
|
-
/*return*/
|
|
50545
|
-
];
|
|
50029
|
+
return [2 /*return*/];
|
|
50546
50030
|
}
|
|
50547
50031
|
});
|
|
50548
50032
|
});
|
|
@@ -50552,17 +50036,13 @@ function () {
|
|
|
50552
50036
|
part.emitter.removeAllListeners(_axios_http_handler__WEBPACK_IMPORTED_MODULE_2__["SEND_UPLOAD_PROGRESS_EVENT"]);
|
|
50553
50037
|
part.emitter.removeAllListeners(_axios_http_handler__WEBPACK_IMPORTED_MODULE_2__["SEND_DOWNLOAD_PROGRESS_EVENT"]);
|
|
50554
50038
|
};
|
|
50555
|
-
|
|
50556
50039
|
AWSS3ProviderManagedUpload.prototype.setupEventListener = function (part) {
|
|
50557
50040
|
var _this = this;
|
|
50558
|
-
|
|
50559
50041
|
part.emitter.on(_axios_http_handler__WEBPACK_IMPORTED_MODULE_2__["SEND_UPLOAD_PROGRESS_EVENT"], function (progress) {
|
|
50560
50042
|
_this.progressChanged(part.partNumber, progress.loaded - part._lastUploadedBytes);
|
|
50561
|
-
|
|
50562
50043
|
part._lastUploadedBytes = progress.loaded;
|
|
50563
50044
|
});
|
|
50564
50045
|
};
|
|
50565
|
-
|
|
50566
50046
|
AWSS3ProviderManagedUpload.prototype.progressChanged = function (partNumber, incrementalUpdate) {
|
|
50567
50047
|
this.bytesUploaded += incrementalUpdate;
|
|
50568
50048
|
this.emitter.emit(_axios_http_handler__WEBPACK_IMPORTED_MODULE_2__["SEND_UPLOAD_PROGRESS_EVENT"], {
|
|
@@ -50572,10 +50052,8 @@ function () {
|
|
|
50572
50052
|
key: this.params.Key
|
|
50573
50053
|
});
|
|
50574
50054
|
};
|
|
50575
|
-
|
|
50576
50055
|
AWSS3ProviderManagedUpload.prototype.byteLength = function (input) {
|
|
50577
50056
|
if (input === null || input === undefined) return 0;
|
|
50578
|
-
|
|
50579
50057
|
if (typeof input.byteLength === 'number') {
|
|
50580
50058
|
return input.byteLength;
|
|
50581
50059
|
} else if (typeof input.length === 'number') {
|
|
@@ -50590,25 +50068,17 @@ function () {
|
|
|
50590
50068
|
throw new Error('Cannot determine length of ' + input);
|
|
50591
50069
|
}
|
|
50592
50070
|
};
|
|
50593
|
-
|
|
50594
50071
|
AWSS3ProviderManagedUpload.prototype.validateAndSanitizeBody = function (body) {
|
|
50595
50072
|
return __awaiter(this, void 0, void 0, function () {
|
|
50596
50073
|
return __generator(this, function (_a) {
|
|
50597
50074
|
if (this.isGenericObject(body)) {
|
|
50598
50075
|
// Any javascript object
|
|
50599
|
-
return [2
|
|
50600
|
-
/*return*/
|
|
50601
|
-
, JSON.stringify(body)];
|
|
50076
|
+
return [2 /*return*/, JSON.stringify(body)];
|
|
50602
50077
|
} else {
|
|
50603
50078
|
// Files, arrayBuffer etc
|
|
50604
|
-
return [2
|
|
50605
|
-
/*return*/
|
|
50606
|
-
, body];
|
|
50079
|
+
return [2 /*return*/, body];
|
|
50607
50080
|
}
|
|
50608
|
-
|
|
50609
|
-
return [2
|
|
50610
|
-
/*return*/
|
|
50611
|
-
];
|
|
50081
|
+
return [2 /*return*/];
|
|
50612
50082
|
});
|
|
50613
50083
|
});
|
|
50614
50084
|
};
|
|
@@ -50623,22 +50093,18 @@ function () {
|
|
|
50623
50093
|
return true;
|
|
50624
50094
|
}
|
|
50625
50095
|
}
|
|
50626
|
-
|
|
50627
50096
|
return false;
|
|
50628
50097
|
};
|
|
50629
|
-
|
|
50630
50098
|
AWSS3ProviderManagedUpload.prototype._createNewS3Client = function (config, emitter) {
|
|
50631
50099
|
var s3client = Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_4__["createS3Client"])(config, emitter);
|
|
50632
50100
|
s3client.middlewareStack.add(Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_4__["createPrefixMiddleware"])(this.opts, this.params.Key), _common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_4__["prefixMiddlewareOptions"]);
|
|
50633
50101
|
s3client.middlewareStack.add(Object(_common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_4__["autoAdjustClockskewMiddleware"])(s3client.config), _common_S3ClientUtils__WEBPACK_IMPORTED_MODULE_4__["autoAdjustClockskewMiddlewareOptions"]);
|
|
50634
50102
|
return s3client;
|
|
50635
50103
|
};
|
|
50636
|
-
|
|
50637
50104
|
return AWSS3ProviderManagedUpload;
|
|
50638
50105
|
}();
|
|
50639
50106
|
|
|
50640
50107
|
|
|
50641
|
-
|
|
50642
50108
|
/***/ }),
|
|
50643
50109
|
|
|
50644
50110
|
/***/ "./lib-esm/providers/AWSS3UploadTask.js":
|
|
@@ -50667,7 +50133,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
50667
50133
|
resolve(value);
|
|
50668
50134
|
});
|
|
50669
50135
|
}
|
|
50670
|
-
|
|
50671
50136
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50672
50137
|
function fulfilled(value) {
|
|
50673
50138
|
try {
|
|
@@ -50676,7 +50141,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
50676
50141
|
reject(e);
|
|
50677
50142
|
}
|
|
50678
50143
|
}
|
|
50679
|
-
|
|
50680
50144
|
function rejected(value) {
|
|
50681
50145
|
try {
|
|
50682
50146
|
step(generator["throw"](value));
|
|
@@ -50684,29 +50148,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
50684
50148
|
reject(e);
|
|
50685
50149
|
}
|
|
50686
50150
|
}
|
|
50687
|
-
|
|
50688
50151
|
function step(result) {
|
|
50689
50152
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
50690
50153
|
}
|
|
50691
|
-
|
|
50692
50154
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50693
50155
|
});
|
|
50694
50156
|
};
|
|
50695
|
-
|
|
50696
50157
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
50697
50158
|
var _ = {
|
|
50698
|
-
|
|
50699
|
-
|
|
50700
|
-
|
|
50701
|
-
|
|
50159
|
+
label: 0,
|
|
50160
|
+
sent: function sent() {
|
|
50161
|
+
if (t[0] & 1) throw t[1];
|
|
50162
|
+
return t[1];
|
|
50163
|
+
},
|
|
50164
|
+
trys: [],
|
|
50165
|
+
ops: []
|
|
50702
50166
|
},
|
|
50703
|
-
|
|
50704
|
-
|
|
50705
|
-
|
|
50706
|
-
|
|
50707
|
-
y,
|
|
50708
|
-
t,
|
|
50709
|
-
g;
|
|
50167
|
+
f,
|
|
50168
|
+
y,
|
|
50169
|
+
t,
|
|
50170
|
+
g;
|
|
50710
50171
|
return g = {
|
|
50711
50172
|
next: verb(0),
|
|
50712
50173
|
"throw": verb(1),
|
|
@@ -50714,79 +50175,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50714
50175
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
50715
50176
|
return this;
|
|
50716
50177
|
}), g;
|
|
50717
|
-
|
|
50718
50178
|
function verb(n) {
|
|
50719
50179
|
return function (v) {
|
|
50720
50180
|
return step([n, v]);
|
|
50721
50181
|
};
|
|
50722
50182
|
}
|
|
50723
|
-
|
|
50724
50183
|
function step(op) {
|
|
50725
50184
|
if (f) throw new TypeError("Generator is already executing.");
|
|
50726
|
-
|
|
50727
50185
|
while (_) {
|
|
50728
50186
|
try {
|
|
50729
50187
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50730
50188
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50731
|
-
|
|
50732
50189
|
switch (op[0]) {
|
|
50733
50190
|
case 0:
|
|
50734
50191
|
case 1:
|
|
50735
50192
|
t = op;
|
|
50736
50193
|
break;
|
|
50737
|
-
|
|
50738
50194
|
case 4:
|
|
50739
50195
|
_.label++;
|
|
50740
50196
|
return {
|
|
50741
50197
|
value: op[1],
|
|
50742
50198
|
done: false
|
|
50743
50199
|
};
|
|
50744
|
-
|
|
50745
50200
|
case 5:
|
|
50746
50201
|
_.label++;
|
|
50747
50202
|
y = op[1];
|
|
50748
50203
|
op = [0];
|
|
50749
50204
|
continue;
|
|
50750
|
-
|
|
50751
50205
|
case 7:
|
|
50752
50206
|
op = _.ops.pop();
|
|
50753
|
-
|
|
50754
50207
|
_.trys.pop();
|
|
50755
|
-
|
|
50756
50208
|
continue;
|
|
50757
|
-
|
|
50758
50209
|
default:
|
|
50759
50210
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
50760
50211
|
_ = 0;
|
|
50761
50212
|
continue;
|
|
50762
50213
|
}
|
|
50763
|
-
|
|
50764
50214
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
50765
50215
|
_.label = op[1];
|
|
50766
50216
|
break;
|
|
50767
50217
|
}
|
|
50768
|
-
|
|
50769
50218
|
if (op[0] === 6 && _.label < t[1]) {
|
|
50770
50219
|
_.label = t[1];
|
|
50771
50220
|
t = op;
|
|
50772
50221
|
break;
|
|
50773
50222
|
}
|
|
50774
|
-
|
|
50775
50223
|
if (t && _.label < t[2]) {
|
|
50776
50224
|
_.label = t[2];
|
|
50777
|
-
|
|
50778
50225
|
_.ops.push(op);
|
|
50779
|
-
|
|
50780
50226
|
break;
|
|
50781
50227
|
}
|
|
50782
|
-
|
|
50783
50228
|
if (t[2]) _.ops.pop();
|
|
50784
|
-
|
|
50785
50229
|
_.trys.pop();
|
|
50786
|
-
|
|
50787
50230
|
continue;
|
|
50788
50231
|
}
|
|
50789
|
-
|
|
50790
50232
|
op = body.call(thisArg, _);
|
|
50791
50233
|
} catch (e) {
|
|
50792
50234
|
op = [6, e];
|
|
@@ -50795,7 +50237,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50795
50237
|
f = t = 0;
|
|
50796
50238
|
}
|
|
50797
50239
|
}
|
|
50798
|
-
|
|
50799
50240
|
if (op[0] & 5) throw op[1];
|
|
50800
50241
|
return {
|
|
50801
50242
|
value: op[0] ? op[1] : void 0,
|
|
@@ -50803,15 +50244,13 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
50803
50244
|
};
|
|
50804
50245
|
}
|
|
50805
50246
|
};
|
|
50806
|
-
|
|
50807
50247
|
var __read = undefined && undefined.__read || function (o, n) {
|
|
50808
50248
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50809
50249
|
if (!m) return o;
|
|
50810
50250
|
var i = m.call(o),
|
|
50811
|
-
|
|
50812
|
-
|
|
50813
|
-
|
|
50814
|
-
|
|
50251
|
+
r,
|
|
50252
|
+
ar = [],
|
|
50253
|
+
e;
|
|
50815
50254
|
try {
|
|
50816
50255
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
50817
50256
|
ar.push(r.value);
|
|
@@ -50827,15 +50266,12 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
50827
50266
|
if (e) throw e.error;
|
|
50828
50267
|
}
|
|
50829
50268
|
}
|
|
50830
|
-
|
|
50831
50269
|
return ar;
|
|
50832
50270
|
};
|
|
50833
|
-
|
|
50834
50271
|
var __spread = undefined && undefined.__spread || function () {
|
|
50835
50272
|
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
50836
50273
|
ar = ar.concat(__read(arguments[i]));
|
|
50837
50274
|
}
|
|
50838
|
-
|
|
50839
50275
|
return ar;
|
|
50840
50276
|
};
|
|
50841
50277
|
|
|
@@ -50844,10 +50280,8 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
50844
50280
|
|
|
50845
50281
|
|
|
50846
50282
|
|
|
50847
|
-
|
|
50848
50283
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["Logger"]('AWSS3UploadTask');
|
|
50849
50284
|
var AWSS3UploadTaskState;
|
|
50850
|
-
|
|
50851
50285
|
(function (AWSS3UploadTaskState) {
|
|
50852
50286
|
AWSS3UploadTaskState[AWSS3UploadTaskState["INIT"] = 0] = "INIT";
|
|
50853
50287
|
AWSS3UploadTaskState[AWSS3UploadTaskState["IN_PROGRESS"] = 1] = "IN_PROGRESS";
|
|
@@ -50855,38 +50289,31 @@ var AWSS3UploadTaskState;
|
|
|
50855
50289
|
AWSS3UploadTaskState[AWSS3UploadTaskState["CANCELLED"] = 3] = "CANCELLED";
|
|
50856
50290
|
AWSS3UploadTaskState[AWSS3UploadTaskState["COMPLETED"] = 4] = "COMPLETED";
|
|
50857
50291
|
})(AWSS3UploadTaskState || (AWSS3UploadTaskState = {}));
|
|
50858
|
-
|
|
50859
50292
|
var TaskEvents;
|
|
50860
|
-
|
|
50861
50293
|
(function (TaskEvents) {
|
|
50862
50294
|
TaskEvents["CANCEL"] = "cancel";
|
|
50863
50295
|
TaskEvents["UPLOAD_COMPLETE"] = "uploadComplete";
|
|
50864
50296
|
TaskEvents["UPLOAD_PROGRESS"] = "uploadPartProgress";
|
|
50865
50297
|
TaskEvents["ERROR"] = "error";
|
|
50866
|
-
})(TaskEvents || (TaskEvents = {}));
|
|
50298
|
+
})(TaskEvents || (TaskEvents = {}));
|
|
50299
|
+
// maximum number of parts per upload request according the S3 spec,
|
|
50867
50300
|
// see: https://docs.aws.amazon.com/AmazonS3/latest/userguide/qfacts.html
|
|
50868
|
-
|
|
50869
|
-
|
|
50870
|
-
var MAX_PARTS = 10000; // 5MB in bytes
|
|
50871
|
-
|
|
50301
|
+
var MAX_PARTS = 10000;
|
|
50302
|
+
// 5MB in bytes
|
|
50872
50303
|
var PART_SIZE = 5 * 1024 * 1024;
|
|
50873
50304
|
var DEFAULT_QUEUE_SIZE = 4;
|
|
50874
|
-
|
|
50875
50305
|
function comparePartNumber(a, b) {
|
|
50876
50306
|
return a.PartNumber - b.PartNumber;
|
|
50877
50307
|
}
|
|
50878
|
-
|
|
50879
|
-
var AWSS3UploadTask =
|
|
50880
|
-
/** @class */
|
|
50881
|
-
function () {
|
|
50308
|
+
var AWSS3UploadTask = /** @class */function () {
|
|
50882
50309
|
function AWSS3UploadTask(_a) {
|
|
50883
50310
|
var s3Client = _a.s3Client,
|
|
50884
|
-
|
|
50885
|
-
|
|
50886
|
-
|
|
50887
|
-
|
|
50888
|
-
|
|
50889
|
-
|
|
50311
|
+
file = _a.file,
|
|
50312
|
+
emitter = _a.emitter,
|
|
50313
|
+
storage = _a.storage,
|
|
50314
|
+
params = _a.params,
|
|
50315
|
+
level = _a.level,
|
|
50316
|
+
prefixPromise = _a.prefixPromise;
|
|
50890
50317
|
this.partSize = PART_SIZE;
|
|
50891
50318
|
this.queueSize = DEFAULT_QUEUE_SIZE;
|
|
50892
50319
|
this.inProgress = [];
|
|
@@ -50900,11 +50327,9 @@ function () {
|
|
|
50900
50327
|
this.s3client.middlewareStack.remove(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_5__["SET_CONTENT_LENGTH_HEADER"]);
|
|
50901
50328
|
this.storage = storage;
|
|
50902
50329
|
this.storageSync = Promise.resolve();
|
|
50903
|
-
|
|
50904
50330
|
if (typeof this.storage['sync'] === 'function') {
|
|
50905
50331
|
this.storageSync = this.storage['sync']();
|
|
50906
50332
|
}
|
|
50907
|
-
|
|
50908
50333
|
this.params = params;
|
|
50909
50334
|
this.file = file;
|
|
50910
50335
|
this.totalBytes = this.file.size;
|
|
@@ -50912,14 +50337,11 @@ function () {
|
|
|
50912
50337
|
this.emitter = emitter;
|
|
50913
50338
|
this.queued = [];
|
|
50914
50339
|
this.fileId = this._getFileId(level);
|
|
50915
|
-
|
|
50916
|
-
|
|
50340
|
+
this._validateParams();
|
|
50341
|
+
// event emitter will re-throw an error if an event emits an error unless there's a listener, attaching a no-op
|
|
50917
50342
|
// function to it unless user adds their own onError callback
|
|
50918
|
-
|
|
50919
|
-
|
|
50920
50343
|
this.emitter.on(TaskEvents.ERROR, function () {});
|
|
50921
50344
|
}
|
|
50922
|
-
|
|
50923
50345
|
Object.defineProperty(AWSS3UploadTask.prototype, "percent", {
|
|
50924
50346
|
get: function get() {
|
|
50925
50347
|
return this.bytesUploaded / this.totalBytes * 100;
|
|
@@ -50934,43 +50356,32 @@ function () {
|
|
|
50934
50356
|
enumerable: true,
|
|
50935
50357
|
configurable: true
|
|
50936
50358
|
});
|
|
50937
|
-
|
|
50938
50359
|
AWSS3UploadTask.prototype._listSingleFile = function (_a) {
|
|
50939
50360
|
var key = _a.key,
|
|
50940
|
-
|
|
50361
|
+
bucket = _a.bucket;
|
|
50941
50362
|
return __awaiter(this, void 0, void 0, function () {
|
|
50942
50363
|
var listObjectRes, _b, Contents, prefix, obj;
|
|
50943
|
-
|
|
50944
50364
|
return __generator(this, function (_c) {
|
|
50945
50365
|
switch (_c.label) {
|
|
50946
50366
|
case 0:
|
|
50947
|
-
return [4
|
|
50948
|
-
/*yield*/
|
|
50949
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["ListObjectsV2Command"]({
|
|
50367
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["ListObjectsV2Command"]({
|
|
50950
50368
|
Bucket: bucket,
|
|
50951
50369
|
Prefix: key
|
|
50952
50370
|
}))];
|
|
50953
|
-
|
|
50954
50371
|
case 1:
|
|
50955
50372
|
listObjectRes = _c.sent();
|
|
50956
50373
|
_b = listObjectRes.Contents, Contents = _b === void 0 ? [] : _b;
|
|
50957
|
-
return [4
|
|
50958
|
-
/*yield*/
|
|
50959
|
-
, this.prefixPromise];
|
|
50960
|
-
|
|
50374
|
+
return [4 /*yield*/, this.prefixPromise];
|
|
50961
50375
|
case 2:
|
|
50962
50376
|
prefix = _c.sent();
|
|
50963
50377
|
obj = Contents.find(function (o) {
|
|
50964
50378
|
return o.Key === "" + prefix + key;
|
|
50965
50379
|
});
|
|
50966
|
-
return [2
|
|
50967
|
-
/*return*/
|
|
50968
|
-
, obj];
|
|
50380
|
+
return [2 /*return*/, obj];
|
|
50969
50381
|
}
|
|
50970
50382
|
});
|
|
50971
50383
|
});
|
|
50972
50384
|
};
|
|
50973
|
-
|
|
50974
50385
|
AWSS3UploadTask.prototype._getFileId = function (level) {
|
|
50975
50386
|
// We should check if it's a File first because File is also instance of a Blob
|
|
50976
50387
|
if (Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_3__["isFile"])(this.file)) {
|
|
@@ -50979,45 +50390,32 @@ function () {
|
|
|
50979
50390
|
return [this.file.size, this.file.type, this.params.Bucket, level, this.params.Key].join('-');
|
|
50980
50391
|
}
|
|
50981
50392
|
};
|
|
50982
|
-
|
|
50983
50393
|
AWSS3UploadTask.prototype._findCachedUploadParts = function () {
|
|
50984
50394
|
return __awaiter(this, void 0, void 0, function () {
|
|
50985
50395
|
var uploadRequests, cachedUploadFileData, listPartsOutput;
|
|
50986
50396
|
return __generator(this, function (_a) {
|
|
50987
50397
|
switch (_a.label) {
|
|
50988
50398
|
case 0:
|
|
50989
|
-
return [4
|
|
50990
|
-
/*yield*/
|
|
50991
|
-
, this._listCachedUploadTasks()];
|
|
50992
|
-
|
|
50399
|
+
return [4 /*yield*/, this._listCachedUploadTasks()];
|
|
50993
50400
|
case 1:
|
|
50994
50401
|
uploadRequests = _a.sent();
|
|
50995
|
-
|
|
50996
50402
|
if (Object.keys(uploadRequests).length === 0 || !Object.prototype.hasOwnProperty.call(uploadRequests, this.fileId)) {
|
|
50997
|
-
return [2
|
|
50998
|
-
/*return*/
|
|
50999
|
-
, {
|
|
50403
|
+
return [2 /*return*/, {
|
|
51000
50404
|
parts: [],
|
|
51001
50405
|
uploadId: null
|
|
51002
50406
|
}];
|
|
51003
50407
|
}
|
|
51004
|
-
|
|
51005
50408
|
cachedUploadFileData = uploadRequests[this.fileId];
|
|
51006
50409
|
cachedUploadFileData.lastTouched = Date.now();
|
|
51007
50410
|
this.storage.setItem(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_5__["UPLOADS_STORAGE_KEY"], JSON.stringify(uploadRequests));
|
|
51008
|
-
return [4
|
|
51009
|
-
/*yield*/
|
|
51010
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["ListPartsCommand"]({
|
|
50411
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["ListPartsCommand"]({
|
|
51011
50412
|
Bucket: this.params.Bucket,
|
|
51012
50413
|
Key: this.params.Key,
|
|
51013
50414
|
UploadId: cachedUploadFileData.uploadId
|
|
51014
50415
|
}))];
|
|
51015
|
-
|
|
51016
50416
|
case 2:
|
|
51017
50417
|
listPartsOutput = _a.sent();
|
|
51018
|
-
return [2
|
|
51019
|
-
/*return*/
|
|
51020
|
-
, {
|
|
50418
|
+
return [2 /*return*/, {
|
|
51021
50419
|
parts: listPartsOutput.Parts || [],
|
|
51022
50420
|
uploadId: cachedUploadFileData.uploadId
|
|
51023
50421
|
}];
|
|
@@ -51025,56 +50423,41 @@ function () {
|
|
|
51025
50423
|
});
|
|
51026
50424
|
});
|
|
51027
50425
|
};
|
|
51028
|
-
|
|
51029
50426
|
AWSS3UploadTask.prototype._emitEvent = function (event, payload) {
|
|
51030
50427
|
this.emitter.emit(event, payload);
|
|
51031
50428
|
};
|
|
51032
|
-
|
|
51033
50429
|
AWSS3UploadTask.prototype._validateParams = function () {
|
|
51034
50430
|
if (this.file.size / this.partSize > MAX_PARTS) {
|
|
51035
50431
|
throw new Error("Too many parts. Number of parts is " + this.file.size / this.partSize + ", maximum is " + MAX_PARTS + ".");
|
|
51036
50432
|
}
|
|
51037
50433
|
};
|
|
51038
|
-
|
|
51039
50434
|
AWSS3UploadTask.prototype._listCachedUploadTasks = function () {
|
|
51040
50435
|
return __awaiter(this, void 0, void 0, function () {
|
|
51041
50436
|
var tasks;
|
|
51042
50437
|
return __generator(this, function (_a) {
|
|
51043
50438
|
switch (_a.label) {
|
|
51044
50439
|
case 0:
|
|
51045
|
-
return [4
|
|
51046
|
-
/*yield*/
|
|
51047
|
-
, this.storageSync];
|
|
51048
|
-
|
|
50440
|
+
return [4 /*yield*/, this.storageSync];
|
|
51049
50441
|
case 1:
|
|
51050
50442
|
_a.sent();
|
|
51051
|
-
|
|
51052
50443
|
tasks = this.storage.getItem(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_5__["UPLOADS_STORAGE_KEY"]) || '{}';
|
|
51053
|
-
return [2
|
|
51054
|
-
/*return*/
|
|
51055
|
-
, JSON.parse(tasks)];
|
|
50444
|
+
return [2 /*return*/, JSON.parse(tasks)];
|
|
51056
50445
|
}
|
|
51057
50446
|
});
|
|
51058
50447
|
});
|
|
51059
50448
|
};
|
|
51060
|
-
|
|
51061
50449
|
AWSS3UploadTask.prototype._cache = function (fileMetadata) {
|
|
51062
50450
|
return __awaiter(this, void 0, void 0, function () {
|
|
51063
50451
|
var uploadRequests;
|
|
51064
50452
|
return __generator(this, function (_a) {
|
|
51065
50453
|
switch (_a.label) {
|
|
51066
50454
|
case 0:
|
|
51067
|
-
return [4
|
|
51068
|
-
/*yield*/
|
|
51069
|
-
, this._listCachedUploadTasks()];
|
|
51070
|
-
|
|
50455
|
+
return [4 /*yield*/, this._listCachedUploadTasks()];
|
|
51071
50456
|
case 1:
|
|
51072
50457
|
uploadRequests = _a.sent();
|
|
51073
50458
|
uploadRequests[this.fileId] = fileMetadata;
|
|
51074
50459
|
this.storage.setItem(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_5__["UPLOADS_STORAGE_KEY"], JSON.stringify(uploadRequests));
|
|
51075
|
-
return [2
|
|
51076
|
-
/*return*/
|
|
51077
|
-
];
|
|
50460
|
+
return [2 /*return*/];
|
|
51078
50461
|
}
|
|
51079
50462
|
});
|
|
51080
50463
|
});
|
|
@@ -51083,41 +50466,29 @@ function () {
|
|
|
51083
50466
|
AWSS3UploadTask.prototype._isCached = function () {
|
|
51084
50467
|
return __awaiter(this, void 0, void 0, function () {
|
|
51085
50468
|
var _a, _b;
|
|
51086
|
-
|
|
51087
50469
|
return __generator(this, function (_c) {
|
|
51088
50470
|
switch (_c.label) {
|
|
51089
50471
|
case 0:
|
|
51090
50472
|
_b = (_a = Object.prototype.hasOwnProperty).call;
|
|
51091
|
-
return [4
|
|
51092
|
-
/*yield*/
|
|
51093
|
-
, this._listCachedUploadTasks()];
|
|
51094
|
-
|
|
50473
|
+
return [4 /*yield*/, this._listCachedUploadTasks()];
|
|
51095
50474
|
case 1:
|
|
51096
|
-
return [2
|
|
51097
|
-
/*return*/
|
|
51098
|
-
, _b.apply(_a, [_c.sent(), this.fileId])];
|
|
50475
|
+
return [2 /*return*/, _b.apply(_a, [_c.sent(), this.fileId])];
|
|
51099
50476
|
}
|
|
51100
50477
|
});
|
|
51101
50478
|
});
|
|
51102
50479
|
};
|
|
51103
|
-
|
|
51104
50480
|
AWSS3UploadTask.prototype._removeFromCache = function () {
|
|
51105
50481
|
return __awaiter(this, void 0, void 0, function () {
|
|
51106
50482
|
var uploadRequests;
|
|
51107
50483
|
return __generator(this, function (_a) {
|
|
51108
50484
|
switch (_a.label) {
|
|
51109
50485
|
case 0:
|
|
51110
|
-
return [4
|
|
51111
|
-
/*yield*/
|
|
51112
|
-
, this._listCachedUploadTasks()];
|
|
51113
|
-
|
|
50486
|
+
return [4 /*yield*/, this._listCachedUploadTasks()];
|
|
51114
50487
|
case 1:
|
|
51115
50488
|
uploadRequests = _a.sent();
|
|
51116
50489
|
delete uploadRequests[this.fileId];
|
|
51117
50490
|
this.storage.setItem(_common_StorageConstants__WEBPACK_IMPORTED_MODULE_5__["UPLOADS_STORAGE_KEY"], JSON.stringify(uploadRequests));
|
|
51118
|
-
return [2
|
|
51119
|
-
/*return*/
|
|
51120
|
-
];
|
|
50491
|
+
return [2 /*return*/];
|
|
51121
50492
|
}
|
|
51122
50493
|
});
|
|
51123
50494
|
});
|
|
@@ -51125,8 +50496,8 @@ function () {
|
|
|
51125
50496
|
|
|
51126
50497
|
AWSS3UploadTask.prototype._onPartUploadCompletion = function (_a) {
|
|
51127
50498
|
var eTag = _a.eTag,
|
|
51128
|
-
|
|
51129
|
-
|
|
50499
|
+
partNumber = _a.partNumber,
|
|
50500
|
+
chunk = _a.chunk;
|
|
51130
50501
|
return __awaiter(this, void 0, void 0, function () {
|
|
51131
50502
|
return __generator(this, function (_b) {
|
|
51132
50503
|
this.completedParts.push({
|
|
@@ -51134,21 +50505,17 @@ function () {
|
|
|
51134
50505
|
PartNumber: partNumber
|
|
51135
50506
|
});
|
|
51136
50507
|
this.bytesUploaded += Object(_common_StorageUtils__WEBPACK_IMPORTED_MODULE_3__["byteLength"])(chunk);
|
|
51137
|
-
|
|
51138
50508
|
this._emitEvent(TaskEvents.UPLOAD_PROGRESS, {
|
|
51139
50509
|
loaded: this.bytesUploaded,
|
|
51140
50510
|
total: this.totalBytes
|
|
51141
|
-
});
|
|
51142
|
-
|
|
51143
|
-
|
|
50511
|
+
});
|
|
50512
|
+
// Remove the completed item from the inProgress array
|
|
51144
50513
|
this.inProgress = this.inProgress.filter(function (job) {
|
|
51145
50514
|
return job.uploadPartInput.PartNumber !== partNumber;
|
|
51146
50515
|
});
|
|
51147
50516
|
if (this.queued.length && this.state !== AWSS3UploadTaskState.PAUSED) this._startNextPart();
|
|
51148
50517
|
if (this._isDone()) this._completeUpload();
|
|
51149
|
-
return [2
|
|
51150
|
-
/*return*/
|
|
51151
|
-
];
|
|
50518
|
+
return [2 /*return*/];
|
|
51152
50519
|
});
|
|
51153
50520
|
});
|
|
51154
50521
|
};
|
|
@@ -51160,10 +50527,7 @@ function () {
|
|
|
51160
50527
|
switch (_a.label) {
|
|
51161
50528
|
case 0:
|
|
51162
50529
|
_a.trys.push([0, 2,, 3]);
|
|
51163
|
-
|
|
51164
|
-
return [4
|
|
51165
|
-
/*yield*/
|
|
51166
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["CompleteMultipartUploadCommand"]({
|
|
50530
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["CompleteMultipartUploadCommand"]({
|
|
51167
50531
|
Bucket: this.params.Bucket,
|
|
51168
50532
|
Key: this.params.Key,
|
|
51169
50533
|
UploadId: this.uploadId,
|
|
@@ -51172,37 +50536,22 @@ function () {
|
|
|
51172
50536
|
Parts: this.completedParts.sort(comparePartNumber)
|
|
51173
50537
|
}
|
|
51174
50538
|
}))];
|
|
51175
|
-
|
|
51176
50539
|
case 1:
|
|
51177
50540
|
_a.sent();
|
|
51178
|
-
|
|
51179
50541
|
this._verifyFileSize();
|
|
51180
|
-
|
|
51181
50542
|
this._emitEvent(TaskEvents.UPLOAD_COMPLETE, {
|
|
51182
50543
|
key: this.params.Bucket + "/" + this.params.Key
|
|
51183
50544
|
});
|
|
51184
|
-
|
|
51185
50545
|
this._removeFromCache();
|
|
51186
|
-
|
|
51187
50546
|
this.state = AWSS3UploadTaskState.COMPLETED;
|
|
51188
|
-
return [3
|
|
51189
|
-
/*break*/
|
|
51190
|
-
, 3];
|
|
51191
|
-
|
|
50547
|
+
return [3 /*break*/, 3];
|
|
51192
50548
|
case 2:
|
|
51193
50549
|
err_1 = _a.sent();
|
|
51194
50550
|
logger.error('error completing upload', err_1);
|
|
51195
|
-
|
|
51196
50551
|
this._emitEvent(TaskEvents.ERROR, err_1);
|
|
51197
|
-
|
|
51198
|
-
return [3
|
|
51199
|
-
/*break*/
|
|
51200
|
-
, 3];
|
|
51201
|
-
|
|
50552
|
+
return [3 /*break*/, 3];
|
|
51202
50553
|
case 3:
|
|
51203
|
-
return [2
|
|
51204
|
-
/*return*/
|
|
51205
|
-
];
|
|
50554
|
+
return [2 /*return*/];
|
|
51206
50555
|
}
|
|
51207
50556
|
});
|
|
51208
50557
|
});
|
|
@@ -51215,57 +50564,37 @@ function () {
|
|
|
51215
50564
|
switch (_a.label) {
|
|
51216
50565
|
case 0:
|
|
51217
50566
|
_a.trys.push([0, 3,, 4]);
|
|
51218
|
-
|
|
51219
|
-
return [4
|
|
51220
|
-
/*yield*/
|
|
51221
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["UploadPartCommand"](input), {
|
|
50567
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["UploadPartCommand"](input), {
|
|
51222
50568
|
cancelTokenSource: cancelTokenSource
|
|
51223
50569
|
})];
|
|
51224
|
-
|
|
51225
50570
|
case 1:
|
|
51226
50571
|
res = _a.sent();
|
|
51227
|
-
return [4
|
|
51228
|
-
/*yield*/
|
|
51229
|
-
, this._onPartUploadCompletion({
|
|
50572
|
+
return [4 /*yield*/, this._onPartUploadCompletion({
|
|
51230
50573
|
eTag: res.ETag,
|
|
51231
50574
|
partNumber: input.PartNumber,
|
|
51232
50575
|
chunk: input.Body
|
|
51233
50576
|
})];
|
|
51234
|
-
|
|
51235
50577
|
case 2:
|
|
51236
50578
|
_a.sent();
|
|
51237
|
-
|
|
51238
|
-
return [3
|
|
51239
|
-
/*break*/
|
|
51240
|
-
, 4];
|
|
51241
|
-
|
|
50579
|
+
return [3 /*break*/, 4];
|
|
51242
50580
|
case 3:
|
|
51243
50581
|
err_2 = _a.sent();
|
|
51244
|
-
|
|
51245
50582
|
if (this.state === AWSS3UploadTaskState.PAUSED) {
|
|
51246
50583
|
logger.log('upload paused');
|
|
51247
50584
|
} else if (this.state === AWSS3UploadTaskState.CANCELLED) {
|
|
51248
50585
|
logger.log('upload aborted');
|
|
51249
50586
|
} else {
|
|
51250
50587
|
logger.error('error starting next part of upload: ', err_2);
|
|
51251
|
-
}
|
|
50588
|
+
}
|
|
50589
|
+
// axios' cancel will also throw an error, however we don't need to emit an event in that case as it's an
|
|
51252
50590
|
// expected behavior
|
|
51253
|
-
|
|
51254
|
-
|
|
51255
50591
|
if (!axios__WEBPACK_IMPORTED_MODULE_1___default.a.isCancel(err_2) && err_2.message !== _common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_4__["AWSS3ProviderUploadErrorStrings"].UPLOAD_PAUSED_MESSAGE) {
|
|
51256
50592
|
this._emitEvent(TaskEvents.ERROR, err_2);
|
|
51257
|
-
|
|
51258
50593
|
this.pause();
|
|
51259
50594
|
}
|
|
51260
|
-
|
|
51261
|
-
return [3
|
|
51262
|
-
/*break*/
|
|
51263
|
-
, 4];
|
|
51264
|
-
|
|
50595
|
+
return [3 /*break*/, 4];
|
|
51265
50596
|
case 4:
|
|
51266
|
-
return [2
|
|
51267
|
-
/*return*/
|
|
51268
|
-
];
|
|
50597
|
+
return [2 /*return*/];
|
|
51269
50598
|
}
|
|
51270
50599
|
});
|
|
51271
50600
|
});
|
|
@@ -51288,45 +50617,33 @@ function () {
|
|
|
51288
50617
|
* @async
|
|
51289
50618
|
* @throws throws an error if the file size does not match between local copy of the file and the file on s3.
|
|
51290
50619
|
*/
|
|
51291
|
-
|
|
51292
|
-
|
|
51293
50620
|
AWSS3UploadTask.prototype._verifyFileSize = function () {
|
|
51294
50621
|
return __awaiter(this, void 0, void 0, function () {
|
|
51295
50622
|
var obj, valid;
|
|
51296
50623
|
return __generator(this, function (_a) {
|
|
51297
50624
|
switch (_a.label) {
|
|
51298
50625
|
case 0:
|
|
51299
|
-
return [4
|
|
51300
|
-
/*yield*/
|
|
51301
|
-
, this._listSingleFile({
|
|
50626
|
+
return [4 /*yield*/, this._listSingleFile({
|
|
51302
50627
|
key: this.params.Key,
|
|
51303
50628
|
bucket: this.params.Bucket
|
|
51304
50629
|
})];
|
|
51305
|
-
|
|
51306
50630
|
case 1:
|
|
51307
50631
|
obj = _a.sent();
|
|
51308
50632
|
valid = Boolean(obj && obj.Size === this.file.size);
|
|
51309
|
-
|
|
51310
50633
|
if (!valid) {
|
|
51311
50634
|
throw new Error('File size does not match between local file and file on s3');
|
|
51312
50635
|
}
|
|
51313
|
-
|
|
51314
|
-
return [2
|
|
51315
|
-
/*return*/
|
|
51316
|
-
, valid];
|
|
50636
|
+
return [2 /*return*/, valid];
|
|
51317
50637
|
}
|
|
51318
50638
|
});
|
|
51319
50639
|
});
|
|
51320
50640
|
};
|
|
51321
|
-
|
|
51322
50641
|
AWSS3UploadTask.prototype._isDone = function () {
|
|
51323
50642
|
return !this.queued.length && !this.inProgress.length && this.bytesUploaded === this.totalBytes;
|
|
51324
50643
|
};
|
|
51325
|
-
|
|
51326
50644
|
AWSS3UploadTask.prototype._createParts = function () {
|
|
51327
50645
|
var size = this.file.size;
|
|
51328
50646
|
var parts = [];
|
|
51329
|
-
|
|
51330
50647
|
for (var bodyStart = 0; bodyStart < size;) {
|
|
51331
50648
|
var bodyEnd = Math.min(bodyStart + this.partSize, size);
|
|
51332
50649
|
parts.push({
|
|
@@ -51338,15 +50655,13 @@ function () {
|
|
|
51338
50655
|
});
|
|
51339
50656
|
bodyStart += this.partSize;
|
|
51340
50657
|
}
|
|
51341
|
-
|
|
51342
50658
|
return parts;
|
|
51343
50659
|
};
|
|
51344
|
-
|
|
51345
50660
|
AWSS3UploadTask.prototype._initCachedUploadParts = function (cachedParts) {
|
|
51346
50661
|
this.bytesUploaded += cachedParts.reduce(function (acc, part) {
|
|
51347
50662
|
return acc + part.Size;
|
|
51348
|
-
}, 0);
|
|
51349
|
-
|
|
50663
|
+
}, 0);
|
|
50664
|
+
// Find the set of part numbers that have already been uploaded
|
|
51350
50665
|
var uploadedPartNumSet = new Set(cachedParts.map(function (part) {
|
|
51351
50666
|
return part.PartNumber;
|
|
51352
50667
|
}));
|
|
@@ -51359,26 +50674,20 @@ function () {
|
|
|
51359
50674
|
ETag: part.ETag
|
|
51360
50675
|
};
|
|
51361
50676
|
});
|
|
51362
|
-
|
|
51363
50677
|
this._emitEvent(TaskEvents.UPLOAD_PROGRESS, {
|
|
51364
50678
|
loaded: this.bytesUploaded,
|
|
51365
50679
|
total: this.totalBytes
|
|
51366
50680
|
});
|
|
51367
50681
|
};
|
|
51368
|
-
|
|
51369
50682
|
AWSS3UploadTask.prototype._initMultipartUpload = function () {
|
|
51370
50683
|
return __awaiter(this, void 0, void 0, function () {
|
|
51371
50684
|
var res;
|
|
51372
50685
|
return __generator(this, function (_a) {
|
|
51373
50686
|
switch (_a.label) {
|
|
51374
50687
|
case 0:
|
|
51375
|
-
return [4
|
|
51376
|
-
/*yield*/
|
|
51377
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["CreateMultipartUploadCommand"](this.params))];
|
|
51378
|
-
|
|
50688
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["CreateMultipartUploadCommand"](this.params))];
|
|
51379
50689
|
case 1:
|
|
51380
50690
|
res = _a.sent();
|
|
51381
|
-
|
|
51382
50691
|
this._cache({
|
|
51383
50692
|
uploadId: res.UploadId,
|
|
51384
50693
|
lastTouched: Date.now(),
|
|
@@ -51386,90 +50695,51 @@ function () {
|
|
|
51386
50695
|
key: this.params.Key,
|
|
51387
50696
|
fileName: this.file instanceof File ? this.file.name : ''
|
|
51388
50697
|
});
|
|
51389
|
-
|
|
51390
|
-
return [2
|
|
51391
|
-
/*return*/
|
|
51392
|
-
, res.UploadId];
|
|
50698
|
+
return [2 /*return*/, res.UploadId];
|
|
51393
50699
|
}
|
|
51394
50700
|
});
|
|
51395
50701
|
});
|
|
51396
50702
|
};
|
|
51397
|
-
|
|
51398
50703
|
AWSS3UploadTask.prototype._initializeUploadTask = function () {
|
|
51399
50704
|
return __awaiter(this, void 0, void 0, function () {
|
|
51400
50705
|
var _a, parts, uploadId, uploadId, err_3;
|
|
51401
|
-
|
|
51402
50706
|
return __generator(this, function (_b) {
|
|
51403
50707
|
switch (_b.label) {
|
|
51404
50708
|
case 0:
|
|
51405
50709
|
this.state = AWSS3UploadTaskState.IN_PROGRESS;
|
|
51406
50710
|
_b.label = 1;
|
|
51407
|
-
|
|
51408
50711
|
case 1:
|
|
51409
50712
|
_b.trys.push([1, 7,, 8]);
|
|
51410
|
-
|
|
51411
|
-
return [4
|
|
51412
|
-
/*yield*/
|
|
51413
|
-
, this._isCached()];
|
|
51414
|
-
|
|
50713
|
+
return [4 /*yield*/, this._isCached()];
|
|
51415
50714
|
case 2:
|
|
51416
|
-
if (!_b.sent()) return [3
|
|
51417
|
-
/*
|
|
51418
|
-
, 4];
|
|
51419
|
-
return [4
|
|
51420
|
-
/*yield*/
|
|
51421
|
-
, this._findCachedUploadParts()];
|
|
51422
|
-
|
|
50715
|
+
if (!_b.sent()) return [3 /*break*/, 4];
|
|
50716
|
+
return [4 /*yield*/, this._findCachedUploadParts()];
|
|
51423
50717
|
case 3:
|
|
51424
50718
|
_a = _b.sent(), parts = _a.parts, uploadId = _a.uploadId;
|
|
51425
50719
|
this.uploadId = uploadId;
|
|
51426
50720
|
this.queued = this._createParts();
|
|
51427
|
-
|
|
51428
50721
|
this._initCachedUploadParts(parts);
|
|
51429
|
-
|
|
51430
50722
|
this._startUpload();
|
|
51431
|
-
|
|
51432
|
-
return [3
|
|
51433
|
-
/*break*/
|
|
51434
|
-
, 6];
|
|
51435
|
-
|
|
50723
|
+
return [3 /*break*/, 6];
|
|
51436
50724
|
case 4:
|
|
51437
|
-
if (!!this.uploadId) return [3
|
|
51438
|
-
/*
|
|
51439
|
-
, 6];
|
|
51440
|
-
return [4
|
|
51441
|
-
/*yield*/
|
|
51442
|
-
, this._initMultipartUpload()];
|
|
51443
|
-
|
|
50725
|
+
if (!!this.uploadId) return [3 /*break*/, 6];
|
|
50726
|
+
return [4 /*yield*/, this._initMultipartUpload()];
|
|
51444
50727
|
case 5:
|
|
51445
50728
|
uploadId = _b.sent();
|
|
51446
50729
|
this.uploadId = uploadId;
|
|
51447
50730
|
this.queued = this._createParts();
|
|
51448
|
-
|
|
51449
50731
|
this._startUpload();
|
|
51450
|
-
|
|
51451
50732
|
_b.label = 6;
|
|
51452
|
-
|
|
51453
50733
|
case 6:
|
|
51454
|
-
return [3
|
|
51455
|
-
/*break*/
|
|
51456
|
-
, 8];
|
|
51457
|
-
|
|
50734
|
+
return [3 /*break*/, 8];
|
|
51458
50735
|
case 7:
|
|
51459
50736
|
err_3 = _b.sent();
|
|
51460
|
-
|
|
51461
50737
|
if (!axios__WEBPACK_IMPORTED_MODULE_1___default.a.isCancel(err_3)) {
|
|
51462
50738
|
logger.error('Error initializing the upload task', err_3);
|
|
51463
50739
|
}
|
|
51464
|
-
|
|
51465
|
-
return [3
|
|
51466
|
-
/*break*/
|
|
51467
|
-
, 8];
|
|
51468
|
-
|
|
50740
|
+
return [3 /*break*/, 8];
|
|
51469
50741
|
case 8:
|
|
51470
|
-
return [2
|
|
51471
|
-
/*return*/
|
|
51472
|
-
];
|
|
50742
|
+
return [2 /*return*/];
|
|
51473
50743
|
}
|
|
51474
50744
|
});
|
|
51475
50745
|
});
|
|
@@ -51481,7 +50751,8 @@ function () {
|
|
|
51481
50751
|
} else if (this.state === AWSS3UploadTaskState.COMPLETED) {
|
|
51482
50752
|
logger.warn('This task has already been completed');
|
|
51483
50753
|
} else if (this.state === AWSS3UploadTaskState.IN_PROGRESS) {
|
|
51484
|
-
logger.warn('Upload task already in progress');
|
|
50754
|
+
logger.warn('Upload task already in progress');
|
|
50755
|
+
// first time running resume, find any cached parts on s3 or start a new multipart upload request before
|
|
51485
50756
|
// starting the upload
|
|
51486
50757
|
} else if (!this.uploadId) {
|
|
51487
50758
|
this._initializeUploadTask();
|
|
@@ -51489,38 +50760,25 @@ function () {
|
|
|
51489
50760
|
this._startUpload();
|
|
51490
50761
|
}
|
|
51491
50762
|
};
|
|
51492
|
-
|
|
51493
50763
|
AWSS3UploadTask.prototype._startUpload = function () {
|
|
51494
50764
|
this.state = AWSS3UploadTaskState.IN_PROGRESS;
|
|
51495
|
-
|
|
51496
50765
|
for (var i = 0; i < this.queueSize; i++) {
|
|
51497
50766
|
this._startNextPart();
|
|
51498
50767
|
}
|
|
51499
50768
|
};
|
|
51500
|
-
|
|
51501
50769
|
AWSS3UploadTask.prototype._cancel = function () {
|
|
51502
50770
|
return __awaiter(this, void 0, void 0, function () {
|
|
51503
50771
|
var err_4;
|
|
51504
50772
|
return __generator(this, function (_a) {
|
|
51505
50773
|
switch (_a.label) {
|
|
51506
50774
|
case 0:
|
|
51507
|
-
if (!(this.state === AWSS3UploadTaskState.CANCELLED)) return [3
|
|
51508
|
-
/*break*/
|
|
51509
|
-
, 1];
|
|
50775
|
+
if (!(this.state === AWSS3UploadTaskState.CANCELLED)) return [3 /*break*/, 1];
|
|
51510
50776
|
logger.warn('This task has already been cancelled');
|
|
51511
|
-
return [2
|
|
51512
|
-
/*return*/
|
|
51513
|
-
, false];
|
|
51514
|
-
|
|
50777
|
+
return [2 /*return*/, false];
|
|
51515
50778
|
case 1:
|
|
51516
|
-
if (!(this.state === AWSS3UploadTaskState.COMPLETED)) return [3
|
|
51517
|
-
/*break*/
|
|
51518
|
-
, 2];
|
|
50779
|
+
if (!(this.state === AWSS3UploadTaskState.COMPLETED)) return [3 /*break*/, 2];
|
|
51519
50780
|
logger.warn('This task has already been completed');
|
|
51520
|
-
return [2
|
|
51521
|
-
/*return*/
|
|
51522
|
-
, false];
|
|
51523
|
-
|
|
50781
|
+
return [2 /*return*/, false];
|
|
51524
50782
|
case 2:
|
|
51525
50783
|
this.pause();
|
|
51526
50784
|
this.queued = [];
|
|
@@ -51528,43 +50786,25 @@ function () {
|
|
|
51528
50786
|
this.bytesUploaded = 0;
|
|
51529
50787
|
this.state = AWSS3UploadTaskState.CANCELLED;
|
|
51530
50788
|
_a.label = 3;
|
|
51531
|
-
|
|
51532
50789
|
case 3:
|
|
51533
50790
|
_a.trys.push([3, 6,, 7]);
|
|
51534
|
-
|
|
51535
|
-
return [4
|
|
51536
|
-
/*yield*/
|
|
51537
|
-
, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["AbortMultipartUploadCommand"]({
|
|
50791
|
+
return [4 /*yield*/, this.s3client.send(new _aws_sdk_client_s3__WEBPACK_IMPORTED_MODULE_0__["AbortMultipartUploadCommand"]({
|
|
51538
50792
|
Bucket: this.params.Bucket,
|
|
51539
50793
|
Key: this.params.Key,
|
|
51540
50794
|
UploadId: this.uploadId
|
|
51541
50795
|
}))];
|
|
51542
|
-
|
|
51543
50796
|
case 4:
|
|
51544
50797
|
_a.sent();
|
|
51545
|
-
|
|
51546
|
-
return [4
|
|
51547
|
-
/*yield*/
|
|
51548
|
-
, this._removeFromCache()];
|
|
51549
|
-
|
|
50798
|
+
return [4 /*yield*/, this._removeFromCache()];
|
|
51550
50799
|
case 5:
|
|
51551
50800
|
_a.sent();
|
|
51552
|
-
|
|
51553
|
-
return [2
|
|
51554
|
-
/*return*/
|
|
51555
|
-
, true];
|
|
51556
|
-
|
|
50801
|
+
return [2 /*return*/, true];
|
|
51557
50802
|
case 6:
|
|
51558
50803
|
err_4 = _a.sent();
|
|
51559
50804
|
logger.error('Error cancelling upload task', err_4);
|
|
51560
|
-
return [2
|
|
51561
|
-
/*return*/
|
|
51562
|
-
, false];
|
|
51563
|
-
|
|
50805
|
+
return [2 /*return*/, false];
|
|
51564
50806
|
case 7:
|
|
51565
|
-
return [2
|
|
51566
|
-
/*return*/
|
|
51567
|
-
];
|
|
50807
|
+
return [2 /*return*/];
|
|
51568
50808
|
}
|
|
51569
50809
|
});
|
|
51570
50810
|
});
|
|
@@ -51572,11 +50812,8 @@ function () {
|
|
|
51572
50812
|
/**
|
|
51573
50813
|
* pause this particular upload task
|
|
51574
50814
|
**/
|
|
51575
|
-
|
|
51576
|
-
|
|
51577
50815
|
AWSS3UploadTask.prototype.pause = function () {
|
|
51578
50816
|
var _a;
|
|
51579
|
-
|
|
51580
50817
|
if (this.state === AWSS3UploadTaskState.CANCELLED) {
|
|
51581
50818
|
logger.warn('This task has already been cancelled');
|
|
51582
50819
|
} else if (this.state === AWSS3UploadTaskState.COMPLETED) {
|
|
@@ -51584,25 +50821,22 @@ function () {
|
|
|
51584
50821
|
} else if (this.state === AWSS3UploadTaskState.PAUSED) {
|
|
51585
50822
|
logger.warn('This task is already paused');
|
|
51586
50823
|
}
|
|
51587
|
-
|
|
51588
|
-
|
|
50824
|
+
this.state = AWSS3UploadTaskState.PAUSED;
|
|
50825
|
+
// Use axios cancel token to abort the part request immediately
|
|
51589
50826
|
// Add the inProgress parts back to pending
|
|
51590
|
-
|
|
51591
50827
|
var removedInProgressReq = this.inProgress.splice(0, this.inProgress.length);
|
|
51592
50828
|
removedInProgressReq.forEach(function (req) {
|
|
51593
50829
|
req.cancel(_common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_4__["AWSS3ProviderUploadErrorStrings"].UPLOAD_PAUSED_MESSAGE);
|
|
51594
|
-
});
|
|
51595
|
-
|
|
50830
|
+
});
|
|
50831
|
+
// Put all removed in progress parts back into the queue
|
|
51596
50832
|
(_a = this.queued).unshift.apply(_a, __spread(removedInProgressReq.map(function (req) {
|
|
51597
50833
|
return req.uploadPartInput;
|
|
51598
50834
|
})));
|
|
51599
50835
|
};
|
|
51600
|
-
|
|
51601
50836
|
return AWSS3UploadTask;
|
|
51602
50837
|
}();
|
|
51603
50838
|
|
|
51604
50839
|
|
|
51605
|
-
|
|
51606
50840
|
/***/ }),
|
|
51607
50841
|
|
|
51608
50842
|
/***/ "./lib-esm/providers/axios-http-handler.js":
|
|
@@ -51639,8 +50873,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
51639
50873
|
*/
|
|
51640
50874
|
var __values = undefined && undefined.__values || function (o) {
|
|
51641
50875
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
51642
|
-
|
|
51643
|
-
|
|
50876
|
+
m = s && o[s],
|
|
50877
|
+
i = 0;
|
|
51644
50878
|
if (m) return m.call(o);
|
|
51645
50879
|
if (o && typeof o.length === "number") return {
|
|
51646
50880
|
next: function next() {
|
|
@@ -51653,15 +50887,13 @@ var __values = undefined && undefined.__values || function (o) {
|
|
|
51653
50887
|
};
|
|
51654
50888
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
51655
50889
|
};
|
|
51656
|
-
|
|
51657
50890
|
var __read = undefined && undefined.__read || function (o, n) {
|
|
51658
50891
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51659
50892
|
if (!m) return o;
|
|
51660
50893
|
var i = m.call(o),
|
|
51661
|
-
|
|
51662
|
-
|
|
51663
|
-
|
|
51664
|
-
|
|
50894
|
+
r,
|
|
50895
|
+
ar = [],
|
|
50896
|
+
e;
|
|
51665
50897
|
try {
|
|
51666
50898
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
51667
50899
|
ar.push(r.value);
|
|
@@ -51677,7 +50909,6 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
51677
50909
|
if (e) throw e.error;
|
|
51678
50910
|
}
|
|
51679
50911
|
}
|
|
51680
|
-
|
|
51681
50912
|
return ar;
|
|
51682
50913
|
};
|
|
51683
50914
|
|
|
@@ -51685,28 +50916,22 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
51685
50916
|
|
|
51686
50917
|
|
|
51687
50918
|
|
|
51688
|
-
|
|
51689
50919
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('axios-http-handler');
|
|
51690
50920
|
var SEND_UPLOAD_PROGRESS_EVENT = 'sendUploadProgress';
|
|
51691
50921
|
var SEND_DOWNLOAD_PROGRESS_EVENT = 'sendDownloadProgress';
|
|
51692
|
-
|
|
51693
50922
|
function isBlob(body) {
|
|
51694
50923
|
return typeof Blob !== 'undefined' && body instanceof Blob;
|
|
51695
50924
|
}
|
|
51696
|
-
|
|
51697
50925
|
function hasErrorResponse(error) {
|
|
51698
50926
|
return typeof error !== 'undefined' && Object.prototype.hasOwnProperty.call(error, 'response') && typeof error.response !== 'undefined' && Object.prototype.hasOwnProperty.call(error.response, 'status') && typeof error.response.status === 'number';
|
|
51699
50927
|
}
|
|
51700
|
-
|
|
51701
50928
|
var normalizeHeaders = function normalizeHeaders(headers, normalizedName) {
|
|
51702
50929
|
var e_1, _a;
|
|
51703
|
-
|
|
51704
50930
|
try {
|
|
51705
50931
|
for (var _b = __values(Object.entries(headers)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
51706
50932
|
var _d = __read(_c.value, 2),
|
|
51707
|
-
|
|
51708
|
-
|
|
51709
|
-
|
|
50933
|
+
k = _d[0],
|
|
50934
|
+
v = _d[1];
|
|
51710
50935
|
if (k !== normalizedName && k.toUpperCase() === normalizedName.toUpperCase()) {
|
|
51711
50936
|
headers[normalizedName] = v;
|
|
51712
50937
|
delete headers[k];
|
|
@@ -51724,56 +50949,47 @@ var normalizeHeaders = function normalizeHeaders(headers, normalizedName) {
|
|
|
51724
50949
|
}
|
|
51725
50950
|
}
|
|
51726
50951
|
};
|
|
51727
|
-
|
|
51728
50952
|
var reactNativeRequestTransformer = [function (data, headers) {
|
|
51729
50953
|
if (isBlob(data)) {
|
|
51730
50954
|
normalizeHeaders(headers, 'Content-Type');
|
|
51731
50955
|
normalizeHeaders(headers, 'Accept');
|
|
51732
50956
|
return data;
|
|
51733
|
-
}
|
|
51734
|
-
|
|
51735
|
-
|
|
50957
|
+
}
|
|
50958
|
+
// Axios' default transformRequest is an array
|
|
51736
50959
|
return axios__WEBPACK_IMPORTED_MODULE_2___default.a.defaults.transformRequest[0].call(null, data, headers);
|
|
51737
50960
|
}];
|
|
51738
|
-
|
|
51739
|
-
var AxiosHttpHandler =
|
|
51740
|
-
/** @class */
|
|
51741
|
-
function () {
|
|
50961
|
+
var AxiosHttpHandler = /** @class */function () {
|
|
51742
50962
|
function AxiosHttpHandler(httpOptions, emitter, cancelTokenSource) {
|
|
51743
50963
|
if (httpOptions === void 0) {
|
|
51744
50964
|
httpOptions = {};
|
|
51745
50965
|
}
|
|
51746
|
-
|
|
51747
50966
|
this.httpOptions = httpOptions;
|
|
51748
50967
|
this.emitter = emitter;
|
|
51749
50968
|
this.cancelTokenSource = cancelTokenSource;
|
|
51750
50969
|
}
|
|
51751
|
-
|
|
51752
|
-
|
|
50970
|
+
AxiosHttpHandler.prototype.destroy = function () {
|
|
50971
|
+
// Do nothing. TLS and HTTP/2 connection pooling is handled by the
|
|
51753
50972
|
// browser.
|
|
51754
50973
|
};
|
|
51755
|
-
|
|
51756
50974
|
AxiosHttpHandler.prototype.handle = function (request, options) {
|
|
51757
|
-
var requestTimeoutInMs = this.httpOptions.requestTimeout;
|
|
50975
|
+
var requestTimeoutInMs = this.httpOptions.requestTimeout;
|
|
50976
|
+
// prioritize the call specific event emitter, this is useful for multipart upload as each individual parts has
|
|
51758
50977
|
// their own event emitter, without having to create s3client for every individual calls.
|
|
51759
|
-
|
|
51760
50978
|
var emitter = options.emitter || this.emitter;
|
|
51761
50979
|
var path = request.path;
|
|
51762
|
-
|
|
51763
50980
|
if (request.query) {
|
|
51764
50981
|
var queryString = Object(_aws_sdk_querystring_builder__WEBPACK_IMPORTED_MODULE_1__["buildQueryString"])(request.query);
|
|
51765
|
-
|
|
51766
50982
|
if (queryString) {
|
|
51767
50983
|
path += "?" + queryString;
|
|
51768
50984
|
}
|
|
51769
50985
|
}
|
|
51770
|
-
|
|
51771
50986
|
var port = request.port;
|
|
51772
50987
|
var url = request.protocol + "//" + request.hostname + (port ? ":" + port : '') + path;
|
|
51773
50988
|
var axiosRequest = {};
|
|
51774
50989
|
axiosRequest.url = url;
|
|
51775
50990
|
axiosRequest.method = request.method;
|
|
51776
|
-
axiosRequest.headers = request.headers;
|
|
50991
|
+
axiosRequest.headers = request.headers;
|
|
50992
|
+
// The host header is automatically added by the browser and adding it explicitly in the
|
|
51777
50993
|
// axios request throws an error https://github.com/aws-amplify/amplify-js/issues/5376
|
|
51778
50994
|
// This is because the host header is a forbidden header for the http client to set
|
|
51779
50995
|
// see https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name and
|
|
@@ -51782,9 +50998,7 @@ function () {
|
|
|
51782
50998
|
// middleware is that the host header is required to be in the request signature and if
|
|
51783
50999
|
// we remove it from the middlewares, then the request fails because the header is added
|
|
51784
51000
|
// by the browser but is absent from the signature.
|
|
51785
|
-
|
|
51786
51001
|
delete axiosRequest.headers['host'];
|
|
51787
|
-
|
|
51788
51002
|
if (request.body) {
|
|
51789
51003
|
axiosRequest.data = request.body;
|
|
51790
51004
|
} else {
|
|
@@ -51800,40 +51014,34 @@ function () {
|
|
|
51800
51014
|
axiosRequest.data = null;
|
|
51801
51015
|
}
|
|
51802
51016
|
}
|
|
51803
|
-
|
|
51804
51017
|
if (emitter) {
|
|
51805
51018
|
// TODO: Unify linting rules across JS repo
|
|
51806
51019
|
axiosRequest.onUploadProgress = function (event) {
|
|
51807
51020
|
emitter.emit(SEND_UPLOAD_PROGRESS_EVENT, event);
|
|
51808
51021
|
logger.debug(event);
|
|
51809
|
-
};
|
|
51810
|
-
|
|
51811
|
-
|
|
51022
|
+
};
|
|
51023
|
+
// TODO: Unify linting rules across JS repo
|
|
51812
51024
|
axiosRequest.onDownloadProgress = function (event) {
|
|
51813
51025
|
emitter.emit(SEND_DOWNLOAD_PROGRESS_EVENT, event);
|
|
51814
51026
|
logger.debug(event);
|
|
51815
51027
|
};
|
|
51816
|
-
}
|
|
51817
|
-
|
|
51818
|
-
|
|
51028
|
+
}
|
|
51029
|
+
// If a cancel token source is passed down from the provider, allows cancellation of in-flight requests
|
|
51819
51030
|
if (this.cancelTokenSource) {
|
|
51820
51031
|
axiosRequest.cancelToken = this.cancelTokenSource.token;
|
|
51821
51032
|
}
|
|
51822
|
-
|
|
51823
51033
|
if (options.cancelTokenSource) {
|
|
51824
51034
|
axiosRequest.cancelToken = options.cancelTokenSource.token;
|
|
51825
|
-
}
|
|
51826
|
-
|
|
51827
|
-
|
|
51828
|
-
|
|
51035
|
+
}
|
|
51036
|
+
// From gamma release, aws-sdk now expects all response type to be of blob or streams
|
|
51037
|
+
axiosRequest.responseType = 'blob';
|
|
51038
|
+
// In Axios, Blobs are identified by calling Object.prototype.toString on the object. However, on React Native,
|
|
51829
51039
|
// calling Object.prototype.toString on a Blob returns '[object Object]' instead of '[object Blob]', which causes
|
|
51830
51040
|
// Axios to treat Blobs as generic Javascript objects. Therefore we need a to use a custom request transformer
|
|
51831
51041
|
// to correctly handle Blob in React Native.
|
|
51832
|
-
|
|
51833
51042
|
if (_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["Platform"].isReactNative) {
|
|
51834
51043
|
axiosRequest.transformRequest = reactNativeRequestTransformer;
|
|
51835
51044
|
}
|
|
51836
|
-
|
|
51837
51045
|
var raceOfPromises = [axios__WEBPACK_IMPORTED_MODULE_2___default.a.request(axiosRequest).then(function (response) {
|
|
51838
51046
|
return {
|
|
51839
51047
|
response: new _aws_sdk_protocol_http__WEBPACK_IMPORTED_MODULE_0__["HttpResponse"]({
|
|
@@ -51843,25 +51051,22 @@ function () {
|
|
|
51843
51051
|
})
|
|
51844
51052
|
};
|
|
51845
51053
|
})["catch"](function (error) {
|
|
51846
|
-
var _a, _b;
|
|
51847
|
-
|
|
51848
|
-
|
|
51054
|
+
var _a, _b;
|
|
51055
|
+
// Error
|
|
51849
51056
|
if (error.message !== _common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_4__["AWSS3ProviderUploadErrorStrings"].UPLOAD_PAUSED_MESSAGE) {
|
|
51850
51057
|
logger.error(error.message);
|
|
51851
|
-
}
|
|
51058
|
+
}
|
|
51059
|
+
// for axios' cancel error, we should re-throw it back so it's not considered an s3client error
|
|
51852
51060
|
// if we return empty, or an abitrary error HttpResponse, it will be hard to debug down the line.
|
|
51853
51061
|
//
|
|
51854
51062
|
// for errors that does not have a 'response' object, it's very likely that it is an unexpected error for
|
|
51855
51063
|
// example a disconnect. Without it we cannot meaningfully reconstruct a HttpResponse, and the AWS SDK might
|
|
51856
51064
|
// consider the request successful by mistake. In this case we should also re-throw the error.
|
|
51857
|
-
|
|
51858
|
-
|
|
51859
51065
|
if (axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error) || !hasErrorResponse(error)) {
|
|
51860
51066
|
throw error;
|
|
51861
|
-
}
|
|
51067
|
+
}
|
|
51068
|
+
// otherwise, we should re-construct an HttpResponse from the error, so that it can be passed down to other
|
|
51862
51069
|
// aws sdk middleware (e.g retry, clock skew correction, error message serializing)
|
|
51863
|
-
|
|
51864
|
-
|
|
51865
51070
|
return {
|
|
51866
51071
|
response: new _aws_sdk_protocol_http__WEBPACK_IMPORTED_MODULE_0__["HttpResponse"]({
|
|
51867
51072
|
statusCode: error.response.status,
|
|
@@ -51872,17 +51077,13 @@ function () {
|
|
|
51872
51077
|
}), requestTimeout(requestTimeoutInMs)];
|
|
51873
51078
|
return Promise.race(raceOfPromises);
|
|
51874
51079
|
};
|
|
51875
|
-
|
|
51876
51080
|
return AxiosHttpHandler;
|
|
51877
51081
|
}();
|
|
51878
51082
|
|
|
51879
|
-
|
|
51880
|
-
|
|
51881
51083
|
function requestTimeout(timeoutInMs) {
|
|
51882
51084
|
if (timeoutInMs === void 0) {
|
|
51883
51085
|
timeoutInMs = 0;
|
|
51884
51086
|
}
|
|
51885
|
-
|
|
51886
51087
|
return new Promise(function (resolve, reject) {
|
|
51887
51088
|
if (timeoutInMs) {
|
|
51888
51089
|
setTimeout(function () {
|