@aws-amplify/storage 5.6.4-graphql-api-functional-options.1 → 5.6.4-unstable.28bc873.6
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.
- package/lib/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
- package/lib/AwsClients/S3/abortMultipartUpload.js +85 -0
- package/lib/AwsClients/S3/base.d.ts +54 -0
- package/lib/AwsClients/S3/base.js +75 -0
- package/lib/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
- package/lib/AwsClients/S3/completeMultipartUpload.js +162 -0
- package/lib/AwsClients/S3/copyObject.d.ts +24 -0
- package/lib/AwsClients/S3/copyObject.js +98 -0
- package/lib/AwsClients/S3/createMultipartUpload.d.ts +21 -0
- package/lib/AwsClients/S3/createMultipartUpload.js +95 -0
- package/lib/AwsClients/S3/deleteObject.d.ts +20 -0
- package/lib/AwsClients/S3/deleteObject.js +86 -0
- package/lib/AwsClients/S3/getObject.d.ts +27 -0
- package/lib/AwsClients/S3/getObject.js +216 -0
- package/lib/AwsClients/S3/headObject.d.ts +20 -0
- package/lib/AwsClients/S3/headObject.js +96 -0
- package/lib/AwsClients/S3/index.d.ts +13 -0
- package/lib/AwsClients/S3/index.js +30 -0
- package/lib/AwsClients/S3/index.native.d.ts +14 -0
- package/lib/AwsClients/S3/index.native.js +31 -0
- package/lib/AwsClients/S3/listObjectsV2.d.ts +20 -0
- package/lib/AwsClients/S3/listObjectsV2.js +146 -0
- package/lib/AwsClients/S3/listParts.d.ts +20 -0
- package/lib/AwsClients/S3/listParts.js +110 -0
- package/lib/AwsClients/S3/putObject.d.ts +23 -0
- package/lib/AwsClients/S3/putObject.js +93 -0
- package/lib/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
- package/lib/AwsClients/S3/runtime/base64/index.browser.js +20 -0
- package/lib/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
- package/lib/AwsClients/S3/runtime/base64/index.native.js +17 -0
- package/lib/AwsClients/S3/runtime/constants.d.ts +9 -0
- package/lib/AwsClients/S3/runtime/constants.js +14 -0
- package/lib/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
- package/lib/AwsClients/S3/runtime/contentSha256middleware.js +70 -0
- package/lib/AwsClients/S3/runtime/index.browser.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.browser.js +20 -0
- package/lib/AwsClients/S3/runtime/index.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.js +21 -0
- package/lib/AwsClients/S3/runtime/index.native.d.ts +5 -0
- package/lib/AwsClients/S3/runtime/index.native.js +20 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.js +15 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.js +21 -0
- package/lib/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
- package/lib/AwsClients/S3/runtime/xhrTransferHandler.js +201 -0
- package/lib/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
- package/lib/AwsClients/S3/runtime/xmlParser/dom.js +92 -0
- package/lib/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
- package/lib/AwsClients/S3/runtime/xmlParser/pureJs.js +57 -0
- package/lib/AwsClients/S3/types.d.ts +2857 -0
- package/lib/AwsClients/S3/types.js +4 -0
- package/lib/AwsClients/S3/uploadPart.d.ts +20 -0
- package/lib/AwsClients/S3/uploadPart.js +96 -0
- package/lib/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
- package/lib/AwsClients/S3/utils/deserializeHelpers.js +153 -0
- package/lib/AwsClients/S3/utils/index.d.ts +5 -0
- package/lib/AwsClients/S3/utils/index.js +30 -0
- package/lib/AwsClients/S3/utils/parsePayload.d.ts +3 -0
- package/lib/AwsClients/S3/utils/parsePayload.js +96 -0
- package/lib/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
- package/lib/AwsClients/S3/utils/serializeHelpers.js +183 -0
- package/lib/Storage.d.ts +5 -5
- package/lib/Storage.js +60 -31
- package/lib/common/S3ClientUtils.d.ts +24 -15
- package/lib/common/S3ClientUtils.js +83 -95
- package/lib/common/StorageConstants.d.ts +0 -1
- package/lib/common/StorageConstants.js +3 -2
- package/lib/common/StorageErrorStrings.js +3 -1
- package/lib/common/StorageUtils.js +12 -6
- package/lib/index.js +19 -4
- package/lib/providers/AWSS3Provider.d.ts +4 -8
- package/lib/providers/AWSS3Provider.js +210 -139
- package/lib/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
- package/lib/providers/AWSS3ProviderManagedUpload.js +184 -98
- package/lib/providers/AWSS3UploadTask.d.ts +8 -8
- package/lib/providers/AWSS3UploadTask.js +226 -129
- package/lib/providers/index.js +4 -2
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AWSS3Provider.d.ts +62 -62
- package/lib/types/AWSS3Provider.js +0 -1
- package/lib/types/Provider.d.ts +1 -1
- package/lib/types/Provider.js +2 -1
- package/lib/types/Storage.d.ts +23 -23
- package/lib/types/Storage.js +0 -1
- package/lib/types/index.js +17 -1
- package/lib-esm/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
- package/lib-esm/AwsClients/S3/abortMultipartUpload.js +82 -0
- package/lib-esm/AwsClients/S3/base.d.ts +54 -0
- package/lib-esm/AwsClients/S3/base.js +71 -0
- package/lib-esm/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
- package/lib-esm/AwsClients/S3/completeMultipartUpload.js +159 -0
- package/lib-esm/AwsClients/S3/copyObject.d.ts +24 -0
- package/lib-esm/AwsClients/S3/copyObject.js +95 -0
- package/lib-esm/AwsClients/S3/createMultipartUpload.d.ts +21 -0
- package/lib-esm/AwsClients/S3/createMultipartUpload.js +92 -0
- package/lib-esm/AwsClients/S3/deleteObject.d.ts +20 -0
- package/lib-esm/AwsClients/S3/deleteObject.js +83 -0
- package/lib-esm/AwsClients/S3/getObject.d.ts +27 -0
- package/lib-esm/AwsClients/S3/getObject.js +212 -0
- package/lib-esm/AwsClients/S3/headObject.d.ts +20 -0
- package/lib-esm/AwsClients/S3/headObject.js +93 -0
- package/lib-esm/AwsClients/S3/index.d.ts +13 -0
- package/lib-esm/AwsClients/S3/index.js +14 -0
- package/lib-esm/AwsClients/S3/index.native.d.ts +14 -0
- package/lib-esm/AwsClients/S3/index.native.js +15 -0
- package/lib-esm/AwsClients/S3/listObjectsV2.d.ts +20 -0
- package/lib-esm/AwsClients/S3/listObjectsV2.js +143 -0
- package/lib-esm/AwsClients/S3/listParts.d.ts +20 -0
- package/lib-esm/AwsClients/S3/listParts.js +107 -0
- package/lib-esm/AwsClients/S3/putObject.d.ts +23 -0
- package/lib-esm/AwsClients/S3/putObject.js +90 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.browser.js +15 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
- package/lib-esm/AwsClients/S3/runtime/base64/index.native.js +12 -0
- package/lib-esm/AwsClients/S3/runtime/constants.d.ts +9 -0
- package/lib-esm/AwsClients/S3/runtime/constants.js +11 -0
- package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
- package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.js +66 -0
- package/lib-esm/AwsClients/S3/runtime/index.browser.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.browser.js +8 -0
- package/lib-esm/AwsClients/S3/runtime/index.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.js +9 -0
- package/lib-esm/AwsClients/S3/runtime/index.native.d.ts +5 -0
- package/lib-esm/AwsClients/S3/runtime/index.native.js +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.js +12 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.js +18 -0
- package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
- package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.js +196 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.js +89 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
- package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.js +54 -0
- package/lib-esm/AwsClients/S3/types.d.ts +2857 -0
- package/lib-esm/AwsClients/S3/types.js +3 -0
- package/lib-esm/AwsClients/S3/uploadPart.d.ts +20 -0
- package/lib-esm/AwsClients/S3/uploadPart.js +93 -0
- package/lib-esm/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
- package/lib-esm/AwsClients/S3/utils/deserializeHelpers.js +144 -0
- package/lib-esm/AwsClients/S3/utils/index.d.ts +5 -0
- package/lib-esm/AwsClients/S3/utils/index.js +7 -0
- package/lib-esm/AwsClients/S3/utils/parsePayload.d.ts +3 -0
- package/lib-esm/AwsClients/S3/utils/parsePayload.js +91 -0
- package/lib-esm/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
- package/lib-esm/AwsClients/S3/utils/serializeHelpers.js +176 -0
- package/lib-esm/Storage.d.ts +5 -5
- package/lib-esm/Storage.js +53 -25
- package/lib-esm/common/S3ClientUtils.d.ts +24 -15
- package/lib-esm/common/S3ClientUtils.js +76 -93
- package/lib-esm/common/StorageConstants.d.ts +0 -1
- package/lib-esm/common/StorageConstants.js +2 -2
- package/lib-esm/common/StorageErrorStrings.js +2 -1
- package/lib-esm/common/StorageUtils.js +2 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/providers/AWSS3Provider.d.ts +4 -8
- package/lib-esm/providers/AWSS3Provider.js +162 -115
- package/lib-esm/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js +172 -87
- package/lib-esm/providers/AWSS3UploadTask.d.ts +8 -8
- package/lib-esm/providers/AWSS3UploadTask.js +202 -106
- package/lib-esm/providers/index.js +2 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/AWSS3Provider.d.ts +62 -62
- package/lib-esm/types/AWSS3Provider.js +1 -1
- package/lib-esm/types/Provider.d.ts +1 -1
- package/lib-esm/types/Provider.js +3 -1
- package/lib-esm/types/Storage.d.ts +23 -23
- package/lib-esm/types/Storage.js +1 -1
- package/lib-esm/types/index.js +3 -1
- package/package.json +21 -26
- package/src/AwsClients/S3/abortMultipartUpload.ts +62 -0
- package/src/AwsClients/S3/base.ts +109 -0
- package/src/AwsClients/S3/completeMultipartUpload.ts +154 -0
- package/src/AwsClients/S3/copyObject.ts +90 -0
- package/src/AwsClients/S3/createMultipartUpload.ts +75 -0
- package/src/AwsClients/S3/deleteObject.ts +69 -0
- package/src/AwsClients/S3/getObject.ts +173 -0
- package/src/AwsClients/S3/headObject.ts +91 -0
- package/src/AwsClients/S3/index.native.ts +42 -0
- package/src/AwsClients/S3/index.ts +41 -0
- package/src/AwsClients/S3/listObjectsV2.ts +130 -0
- package/src/AwsClients/S3/listParts.ts +97 -0
- package/src/AwsClients/S3/putObject.ts +94 -0
- package/src/AwsClients/S3/runtime/base64/index.browser.ts +21 -0
- package/src/AwsClients/S3/runtime/base64/index.native.ts +16 -0
- package/src/AwsClients/S3/runtime/constants.ts +16 -0
- package/src/AwsClients/S3/runtime/contentSha256middleware.ts +29 -0
- package/src/AwsClients/S3/runtime/index.browser.ts +14 -0
- package/src/AwsClients/S3/runtime/index.native.ts +14 -0
- package/src/AwsClients/S3/runtime/index.ts +15 -0
- package/src/AwsClients/S3/runtime/s3TransferHandler/fetch.ts +23 -0
- package/src/AwsClients/S3/runtime/s3TransferHandler/xhr.ts +35 -0
- package/src/AwsClients/S3/runtime/xhrTransferHandler.ts +254 -0
- package/src/AwsClients/S3/runtime/xmlParser/dom.ts +92 -0
- package/src/AwsClients/S3/runtime/xmlParser/pureJs.ts +55 -0
- package/src/AwsClients/S3/types.ts +2877 -0
- package/src/AwsClients/S3/uploadPart.ts +83 -0
- package/src/AwsClients/S3/utils/deserializeHelpers.ts +136 -0
- package/src/AwsClients/S3/utils/index.ts +27 -0
- package/src/AwsClients/S3/utils/parsePayload.ts +45 -0
- package/src/AwsClients/S3/utils/serializeHelpers.ts +112 -0
- package/src/Storage.ts +30 -27
- package/src/common/S3ClientUtils.ts +57 -113
- package/src/common/StorageConstants.ts +2 -2
- package/src/common/StorageErrorStrings.ts +2 -0
- package/src/common/StorageUtils.ts +2 -0
- package/src/providers/AWSS3Provider.ts +80 -100
- package/src/providers/AWSS3ProviderManagedUpload.ts +56 -63
- package/src/providers/AWSS3UploadTask.ts +86 -87
- package/src/providers/index.ts +2 -0
- package/src/types/AWSS3Provider.ts +55 -49
- package/src/types/Provider.ts +7 -2
- package/lib/.tsbuildinfo +0 -3
- package/lib/Storage.js.map +0 -1
- package/lib/common/S3ClientUtils.js.map +0 -1
- package/lib/common/StorageConstants.js.map +0 -1
- package/lib/common/StorageErrorStrings.js.map +0 -1
- package/lib/common/StorageUtils.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/providers/AWSS3Provider.js.map +0 -1
- package/lib/providers/AWSS3ProviderManagedUpload.js.map +0 -1
- package/lib/providers/AWSS3UploadTask.js.map +0 -1
- package/lib/providers/axios-http-handler.d.ts +0 -40
- package/lib/providers/axios-http-handler.js +0 -193
- package/lib/providers/axios-http-handler.js.map +0 -1
- package/lib/providers/index.js.map +0 -1
- package/lib/types/AWSS3Provider.js.map +0 -1
- package/lib/types/Provider.js.map +0 -1
- package/lib/types/Storage.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Storage.js.map +0 -1
- package/lib-esm/common/S3ClientUtils.js.map +0 -1
- package/lib-esm/common/StorageConstants.js.map +0 -1
- package/lib-esm/common/StorageErrorStrings.js.map +0 -1
- package/lib-esm/common/StorageUtils.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/providers/AWSS3Provider.js.map +0 -1
- package/lib-esm/providers/AWSS3ProviderManagedUpload.js.map +0 -1
- package/lib-esm/providers/AWSS3UploadTask.js.map +0 -1
- package/lib-esm/providers/axios-http-handler.d.ts +0 -40
- package/lib-esm/providers/axios-http-handler.js +0 -191
- package/lib-esm/providers/axios-http-handler.js.map +0 -1
- package/lib-esm/providers/index.js.map +0 -1
- package/lib-esm/types/AWSS3Provider.js.map +0 -1
- package/lib-esm/types/Provider.js.map +0 -1
- package/lib-esm/types/Storage.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/src/providers/axios-http-handler.ts +0 -242
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __values = (this && this.__values) || function(o) {
|
|
49
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
50
|
+
if (m) return m.call(o);
|
|
51
|
+
if (o && typeof o.length === "number") return {
|
|
52
|
+
next: function () {
|
|
53
|
+
if (o && i >= o.length) o = void 0;
|
|
54
|
+
return { value: o && o[i++], done: !o };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
58
|
+
};
|
|
59
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
60
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
61
|
+
if (!m) return o;
|
|
62
|
+
var i = m.call(o), r, ar = [], e;
|
|
63
|
+
try {
|
|
64
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
65
|
+
}
|
|
66
|
+
catch (error) { e = { error: error }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e) throw e.error; }
|
|
72
|
+
}
|
|
73
|
+
return ar;
|
|
74
|
+
};
|
|
75
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
76
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
77
|
+
import { Md5 } from '@aws-sdk/md5-js';
|
|
78
|
+
import { extendedEncodeURIComponent } from '@aws-amplify/core/internals/aws-client-utils';
|
|
79
|
+
import { toBase64, utf8Encode } from '../utils';
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export var assignStringVariables = function (values) {
|
|
84
|
+
var e_1, _a;
|
|
85
|
+
var queryParams = {};
|
|
86
|
+
try {
|
|
87
|
+
for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
88
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
89
|
+
if (value != null) {
|
|
90
|
+
queryParams[key] = value.toString();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
98
|
+
}
|
|
99
|
+
finally { if (e_1) throw e_1.error; }
|
|
100
|
+
}
|
|
101
|
+
return queryParams;
|
|
102
|
+
};
|
|
103
|
+
export var serializeObjectSsecOptionsToHeaders = function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
+
var getMd5Digest, _a, _b, _c, _d;
|
|
105
|
+
var _e;
|
|
106
|
+
return __generator(this, function (_f) {
|
|
107
|
+
switch (_f.label) {
|
|
108
|
+
case 0:
|
|
109
|
+
getMd5Digest = function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
+
var md5Hasher;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
md5Hasher = new Md5();
|
|
113
|
+
md5Hasher.update(utf8Encode(content));
|
|
114
|
+
return [2 /*return*/, md5Hasher.digest()];
|
|
115
|
+
});
|
|
116
|
+
}); };
|
|
117
|
+
_a = assignStringVariables;
|
|
118
|
+
_e = {
|
|
119
|
+
'x-amz-server-side-encryption-customer-algorithm': input.SSECustomerAlgorithm,
|
|
120
|
+
// base64 encoded is need
|
|
121
|
+
// see: https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerSideEncryptionCustomerKeys.html#specifying-s3-c-encryption
|
|
122
|
+
'x-amz-server-side-encryption-customer-key': input.SSECustomerKey && toBase64(input.SSECustomerKey)
|
|
123
|
+
};
|
|
124
|
+
// Calculate the md5 digest of the the SSE-C key, for compatibility with AWS SDK
|
|
125
|
+
// see: https://github.com/aws/aws-sdk-js-v3/blob/91fc83307c38cc9cbe0b3acd919557d5b5b831d6/packages/middleware-ssec/src/index.ts#L36
|
|
126
|
+
_b = 'x-amz-server-side-encryption-customer-key-md5';
|
|
127
|
+
_c = input.SSECustomerKey;
|
|
128
|
+
if (!_c) return [3 /*break*/, 2];
|
|
129
|
+
_d = toBase64;
|
|
130
|
+
return [4 /*yield*/, getMd5Digest(input.SSECustomerKey)];
|
|
131
|
+
case 1:
|
|
132
|
+
_c = _d.apply(void 0, [_f.sent()]);
|
|
133
|
+
_f.label = 2;
|
|
134
|
+
case 2: return [2 /*return*/, _a.apply(void 0, [(
|
|
135
|
+
// Calculate the md5 digest of the the SSE-C key, for compatibility with AWS SDK
|
|
136
|
+
// see: https://github.com/aws/aws-sdk-js-v3/blob/91fc83307c38cc9cbe0b3acd919557d5b5b831d6/packages/middleware-ssec/src/index.ts#L36
|
|
137
|
+
_e[_b] = _c,
|
|
138
|
+
_e)])];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}); };
|
|
142
|
+
/**
|
|
143
|
+
* Serailize the parameters for configuring the S3 object. Currently used by
|
|
144
|
+
* `putObject` and `createMultipartUpload` API.
|
|
145
|
+
*
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export var serializeObjectConfigsToHeaders = function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
var _a;
|
|
150
|
+
var _b;
|
|
151
|
+
return __generator(this, function (_c) {
|
|
152
|
+
switch (_c.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
_a = [{}];
|
|
155
|
+
return [4 /*yield*/, serializeObjectSsecOptionsToHeaders(input)];
|
|
156
|
+
case 1: return [2 /*return*/, (__assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_c.sent())])), assignStringVariables(__assign({ 'x-amz-server-side-encryption': input.ServerSideEncryption, 'x-amz-server-side-encryption-aws-kms-key-id': input.SSEKMSKeyId, 'x-amz-acl': input.ACL, 'cache-control': input.CacheControl, 'content-disposition': input.ContentDisposition, 'content-language': input.ContentLanguage, 'content-encoding': input.ContentEncoding, 'content-type': input.ContentType, expires: (_b = input.Expires) === null || _b === void 0 ? void 0 : _b.toUTCString(), 'x-amz-tagging': input.Tagging }, serializeMetadata(input.Metadata)))]))];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}); };
|
|
160
|
+
var serializeMetadata = function (metadata) {
|
|
161
|
+
if (metadata === void 0) { metadata = {}; }
|
|
162
|
+
return Object.keys(metadata).reduce(function (acc, suffix) {
|
|
163
|
+
acc["x-amz-meta-".concat(suffix.toLowerCase())] = metadata[suffix];
|
|
164
|
+
return acc;
|
|
165
|
+
}, {});
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Serialize the object key to a URL pathname.
|
|
169
|
+
* @see https://github.com/aws/aws-sdk-js-v3/blob/7ed7101dcc4e81038b6c7f581162b959e6b33a04/clients/client-s3/src/protocols/Aws_restXml.ts#L1108
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
export var serializePathnameObjectKey = function (url, key) {
|
|
174
|
+
return (url.pathname.replace(/\/$/, '') +
|
|
175
|
+
"/".concat(key.split('/').map(extendedEncodeURIComponent).join('/')));
|
|
176
|
+
};
|
package/lib-esm/Storage.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare class Storage {
|
|
|
10
10
|
private _pluggables;
|
|
11
11
|
/**
|
|
12
12
|
* Similar to the API module. This weak map allows users to cancel their in-flight request made using the Storage
|
|
13
|
-
* module. For every get or put request, a unique
|
|
14
|
-
*
|
|
15
|
-
* attempt to retrieve it's corresponding
|
|
13
|
+
* module. For every get or put request, a unique AbortConttroller will be generated and injected to it's underlying
|
|
14
|
+
* Xhr HTTP handler. This map maintains a mapping of Request to AbortController. When .cancel is invoked, it will
|
|
15
|
+
* attempt to retrieve it's corresponding abortController and cancel the in-flight request.
|
|
16
16
|
*/
|
|
17
|
-
private
|
|
17
|
+
private _abortControllerMap;
|
|
18
18
|
/**
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
@@ -46,7 +46,7 @@ export declare class Storage {
|
|
|
46
46
|
* @return {Object} - Current configuration
|
|
47
47
|
*/
|
|
48
48
|
configure(config?: any): any;
|
|
49
|
-
private
|
|
49
|
+
private getAbortController;
|
|
50
50
|
private updateRequestToBeCancellable;
|
|
51
51
|
private isUploadTask;
|
|
52
52
|
/**
|
package/lib-esm/Storage.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
15
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
16
|
+
if (!m) return o;
|
|
17
|
+
var i = m.call(o), r, ar = [], e;
|
|
18
|
+
try {
|
|
19
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
20
|
+
}
|
|
21
|
+
catch (error) { e = { error: error }; }
|
|
22
|
+
finally {
|
|
23
|
+
try {
|
|
24
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
25
|
+
}
|
|
26
|
+
finally { if (e) throw e.error; }
|
|
27
|
+
}
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
4
30
|
import { Amplify, ConsoleLogger as Logger, parseAWSExports, } from '@aws-amplify/core';
|
|
5
31
|
import { AWSS3Provider } from './providers';
|
|
6
|
-
import
|
|
32
|
+
import { isCancelError } from './AwsClients/S3/utils';
|
|
7
33
|
import { AWSS3UploadTask } from './providers/AWSS3UploadTask';
|
|
8
34
|
var logger = new Logger('StorageClass');
|
|
9
35
|
var loggerStorageInstance = new Logger('Storage'); // Logging relating to Storage instance management
|
|
@@ -19,7 +45,7 @@ var Storage = /** @class */ (function () {
|
|
|
19
45
|
function Storage() {
|
|
20
46
|
this._config = {};
|
|
21
47
|
this._pluggables = [];
|
|
22
|
-
this.
|
|
48
|
+
this._abortControllerMap = new WeakMap();
|
|
23
49
|
logger.debug('Storage Options', this._config);
|
|
24
50
|
this.get = this.get.bind(this);
|
|
25
51
|
this.put = this.put.bind(this);
|
|
@@ -84,6 +110,7 @@ var Storage = /** @class */ (function () {
|
|
|
84
110
|
'serverSideEncryption',
|
|
85
111
|
'SSECustomerAlgorithm',
|
|
86
112
|
'SSECustomerKey',
|
|
113
|
+
// TODO(AllanZhengYP): remove in V6.
|
|
87
114
|
'SSECustomerKeyMD5',
|
|
88
115
|
'SSEKMSKeyId',
|
|
89
116
|
];
|
|
@@ -117,11 +144,11 @@ var Storage = /** @class */ (function () {
|
|
|
117
144
|
}
|
|
118
145
|
return this._config;
|
|
119
146
|
};
|
|
120
|
-
Storage.prototype.
|
|
121
|
-
return
|
|
147
|
+
Storage.prototype.getAbortController = function () {
|
|
148
|
+
return new AbortController();
|
|
122
149
|
};
|
|
123
|
-
Storage.prototype.updateRequestToBeCancellable = function (request,
|
|
124
|
-
this.
|
|
150
|
+
Storage.prototype.updateRequestToBeCancellable = function (request, abortController) {
|
|
151
|
+
this._abortControllerMap.set(request, abortController);
|
|
125
152
|
};
|
|
126
153
|
Storage.prototype.isUploadTask = function (x) {
|
|
127
154
|
return (typeof x !== 'undefined' &&
|
|
@@ -132,9 +159,11 @@ var Storage = /** @class */ (function () {
|
|
|
132
159
|
if (request instanceof AWSS3UploadTask) {
|
|
133
160
|
return request._cancel();
|
|
134
161
|
}
|
|
135
|
-
var
|
|
136
|
-
if (
|
|
137
|
-
|
|
162
|
+
var abortController = this._abortControllerMap.get(request);
|
|
163
|
+
if (abortController) {
|
|
164
|
+
// TODO: [v6] clean up the aborted promise in the weak map.
|
|
165
|
+
// Not doing it yet to avoid breaking changes when users may abort a request twice.
|
|
166
|
+
abortController.abort(message);
|
|
138
167
|
}
|
|
139
168
|
else {
|
|
140
169
|
logger.debug('The request does not map to any cancel token');
|
|
@@ -147,12 +176,12 @@ var Storage = /** @class */ (function () {
|
|
|
147
176
|
logger.debug('No plugin found with providerName', provider);
|
|
148
177
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
149
178
|
}
|
|
150
|
-
var
|
|
179
|
+
var abortController = this.getAbortController();
|
|
151
180
|
if (typeof plugin.copy !== 'function') {
|
|
152
|
-
return Promise.reject(".copy is not implemented on provider "
|
|
181
|
+
return Promise.reject(".copy is not implemented on provider ".concat(plugin.getProviderName()));
|
|
153
182
|
}
|
|
154
|
-
var responsePromise = plugin.copy(src, dest, __assign(__assign({}, config), {
|
|
155
|
-
this.updateRequestToBeCancellable(responsePromise,
|
|
183
|
+
var responsePromise = plugin.copy(src, dest, __assign(__assign({}, config), { abortSignal: abortController.signal }));
|
|
184
|
+
this.updateRequestToBeCancellable(responsePromise, abortController);
|
|
156
185
|
return responsePromise;
|
|
157
186
|
};
|
|
158
187
|
Storage.prototype.get = function (key, config) {
|
|
@@ -162,13 +191,13 @@ var Storage = /** @class */ (function () {
|
|
|
162
191
|
logger.debug('No plugin found with providerName', provider);
|
|
163
192
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
164
193
|
}
|
|
165
|
-
var
|
|
166
|
-
var responsePromise = plugin.get(key, __assign(__assign({}, config), {
|
|
167
|
-
this.updateRequestToBeCancellable(responsePromise,
|
|
194
|
+
var abortController = this.getAbortController();
|
|
195
|
+
var responsePromise = plugin.get(key, __assign(__assign({}, config), { abortSignal: abortController.signal }));
|
|
196
|
+
this.updateRequestToBeCancellable(responsePromise, abortController);
|
|
168
197
|
return responsePromise;
|
|
169
198
|
};
|
|
170
199
|
Storage.prototype.isCancelError = function (error) {
|
|
171
|
-
return
|
|
200
|
+
return isCancelError(error);
|
|
172
201
|
};
|
|
173
202
|
Storage.prototype.getProperties = function (key, config) {
|
|
174
203
|
var provider = (config === null || config === void 0 ? void 0 : config.provider) || DEFAULT_PROVIDER;
|
|
@@ -177,12 +206,12 @@ var Storage = /** @class */ (function () {
|
|
|
177
206
|
logger.debug('No plugin found with providerName', provider);
|
|
178
207
|
throw new Error('No plugin found with providerName');
|
|
179
208
|
}
|
|
180
|
-
var
|
|
209
|
+
var abortController = this.getAbortController();
|
|
181
210
|
if (typeof plugin.getProperties !== 'function') {
|
|
182
|
-
return Promise.reject(".getProperties is not implemented on provider "
|
|
211
|
+
return Promise.reject(".getProperties is not implemented on provider ".concat(plugin.getProviderName()));
|
|
183
212
|
}
|
|
184
213
|
var responsePromise = plugin === null || plugin === void 0 ? void 0 : plugin.getProperties(key, __assign({}, config));
|
|
185
|
-
this.updateRequestToBeCancellable(responsePromise,
|
|
214
|
+
this.updateRequestToBeCancellable(responsePromise, abortController);
|
|
186
215
|
return responsePromise;
|
|
187
216
|
};
|
|
188
217
|
Storage.prototype.put = function (key, object, config) {
|
|
@@ -192,10 +221,10 @@ var Storage = /** @class */ (function () {
|
|
|
192
221
|
logger.debug('No plugin found with providerName', provider);
|
|
193
222
|
return Promise.reject('No plugin found in Storage for the provider');
|
|
194
223
|
}
|
|
195
|
-
var
|
|
196
|
-
var response = plugin.put(key, object, __assign(__assign({}, config), {
|
|
224
|
+
var abortController = this.getAbortController();
|
|
225
|
+
var response = plugin.put(key, object, __assign(__assign({}, config), { abortSignal: abortController.signal }));
|
|
197
226
|
if (!this.isUploadTask(response)) {
|
|
198
|
-
this.updateRequestToBeCancellable(response,
|
|
227
|
+
this.updateRequestToBeCancellable(response, abortController);
|
|
199
228
|
}
|
|
200
229
|
return response;
|
|
201
230
|
};
|
|
@@ -248,4 +277,3 @@ var getInstance = function () {
|
|
|
248
277
|
};
|
|
249
278
|
export var StorageInstance = getInstance();
|
|
250
279
|
Amplify.register(StorageInstance);
|
|
251
|
-
//# sourceMappingURL=Storage.js.map
|
|
@@ -1,38 +1,47 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ICredentials, StorageAction } from '@aws-amplify/core';
|
|
3
|
+
import type { Credentials as AwsCredentials } from '@aws-sdk/types';
|
|
4
|
+
import type { EventEmitter } from 'events';
|
|
3
5
|
import { StorageAccessLevel, CustomPrefix } from '../types';
|
|
4
|
-
import { InitializeMiddleware, InitializeHandlerOptions, FinalizeRequestHandlerOptions, FinalizeRequestMiddleware } from '@aws-sdk/types';
|
|
5
|
-
import { S3ClientConfig, S3Client } from '@aws-sdk/client-s3';
|
|
6
|
-
import { CancelTokenSource } from 'axios';
|
|
7
|
-
import * as events from 'events';
|
|
8
6
|
export declare const getPrefix: (config: {
|
|
9
7
|
credentials: ICredentials;
|
|
10
8
|
level?: StorageAccessLevel;
|
|
11
9
|
customPrefix?: CustomPrefix;
|
|
12
10
|
identityId?: string;
|
|
13
11
|
}) => string;
|
|
14
|
-
export declare const createPrefixMiddleware: (opt: Record<string, any>, key: string) => InitializeMiddleware<any, any>;
|
|
15
|
-
export declare const autoAdjustClockskewMiddleware: (config: S3ClientConfig) => FinalizeRequestMiddleware<any, any>;
|
|
16
|
-
export declare const autoAdjustClockskewMiddlewareOptions: FinalizeRequestHandlerOptions;
|
|
17
|
-
export declare const prefixMiddlewareOptions: InitializeHandlerOptions;
|
|
18
12
|
export declare const credentialsProvider: () => Promise<{
|
|
19
13
|
accessKeyId: any;
|
|
20
14
|
sessionToken: any;
|
|
21
15
|
secretAccessKey: any;
|
|
22
16
|
identityId: any;
|
|
23
17
|
authenticated: any;
|
|
24
|
-
} | {
|
|
25
|
-
accessKeyId: string;
|
|
26
|
-
secretAccessKey: string;
|
|
27
18
|
}>;
|
|
28
|
-
|
|
19
|
+
interface S3InputConfig {
|
|
20
|
+
credentials?: AwsCredentials;
|
|
29
21
|
region?: string;
|
|
30
|
-
cancelTokenSource?: CancelTokenSource;
|
|
31
|
-
dangerouslyConnectToHttpEndpointForTesting?: boolean;
|
|
32
22
|
useAccelerateEndpoint?: boolean;
|
|
33
|
-
|
|
23
|
+
abortSignal?: AbortSignal;
|
|
24
|
+
emitter?: EventEmitter;
|
|
25
|
+
storageAction: StorageAction;
|
|
26
|
+
dangerouslyConnectToHttpEndpointForTesting?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface S3ResolvedConfig extends Omit<S3InputConfig, 'region' | 'credentials'> {
|
|
29
|
+
region: string;
|
|
30
|
+
userAgentValue?: string;
|
|
31
|
+
credentials: () => Promise<AwsCredentials>;
|
|
32
|
+
customEndpoint?: string;
|
|
33
|
+
forcePathStyle?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A function that persists the s3 configs, so we don't need to
|
|
37
|
+
* assign each config parameter for every s3 API call.
|
|
38
|
+
*
|
|
39
|
+
* @inernal
|
|
40
|
+
*/
|
|
41
|
+
export declare const loadS3Config: (config: S3InputConfig) => S3ResolvedConfig;
|
|
34
42
|
export declare const DEFAULT_PART_SIZE: number;
|
|
35
43
|
export declare const MAX_OBJECT_SIZE: number;
|
|
36
44
|
export declare const MAX_PARTS_COUNT = 10000;
|
|
37
45
|
export declare const DEFAULT_QUEUE_SIZE = 4;
|
|
38
46
|
export declare const calculatePartSize: (totalSize: number) => number;
|
|
47
|
+
export {};
|
|
@@ -1,8 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
49
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
50
|
+
import { Category, Credentials, Logger, getAmplifyUserAgent, } from '@aws-amplify/core';
|
|
51
|
+
import { localTestingStorageEndpoint } from './StorageConstants';
|
|
6
52
|
var logger = new Logger('S3ClientUtils');
|
|
7
53
|
// placeholder credentials in order to satisfy type requirement, always results in 403 when used
|
|
8
54
|
var INVALID_CRED = { accessKeyId: '', secretAccessKey: '' };
|
|
@@ -32,70 +78,6 @@ export var getPrefix = function (config) {
|
|
|
32
78
|
return publicPath;
|
|
33
79
|
}
|
|
34
80
|
};
|
|
35
|
-
export var createPrefixMiddleware = function (opt, key) {
|
|
36
|
-
return function (next, _context) {
|
|
37
|
-
return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
38
|
-
var credentials, cred, prefix, clonedInput, result;
|
|
39
|
-
return __generator(this, function (_a) {
|
|
40
|
-
switch (_a.label) {
|
|
41
|
-
case 0: return [4 /*yield*/, Credentials.get()];
|
|
42
|
-
case 1:
|
|
43
|
-
credentials = _a.sent();
|
|
44
|
-
cred = Credentials.shear(credentials);
|
|
45
|
-
prefix = getPrefix(__assign(__assign({}, opt), { credentials: cred }));
|
|
46
|
-
clonedInput = Object.assign({}, args.input);
|
|
47
|
-
if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) {
|
|
48
|
-
clonedInput.Key = prefix + key;
|
|
49
|
-
args.input = clonedInput;
|
|
50
|
-
}
|
|
51
|
-
else if (Object.prototype.hasOwnProperty.call(args.input, 'Prefix')) {
|
|
52
|
-
clonedInput.Prefix = prefix + key;
|
|
53
|
-
args.input = clonedInput;
|
|
54
|
-
}
|
|
55
|
-
result = next(args);
|
|
56
|
-
return [2 /*return*/, result];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}); };
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
var isTimeSkewedError = function (err) {
|
|
63
|
-
return err.ServerTime &&
|
|
64
|
-
typeof err.Code === 'string' &&
|
|
65
|
-
err.Code === 'RequestTimeTooSkewed';
|
|
66
|
-
};
|
|
67
|
-
// we want to take the S3Client config in parameter so we can modify it's systemClockOffset
|
|
68
|
-
export var autoAdjustClockskewMiddleware = function (config) {
|
|
69
|
-
return function (next, _context) {
|
|
70
|
-
return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var err_1, serverDate;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
_a.trys.push([0, 2, , 3]);
|
|
76
|
-
return [4 /*yield*/, next(args)];
|
|
77
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
78
|
-
case 2:
|
|
79
|
-
err_1 = _a.sent();
|
|
80
|
-
if (isTimeSkewedError(err_1)) {
|
|
81
|
-
serverDate = new Date(err_1.ServerTime);
|
|
82
|
-
config.systemClockOffset = serverDate.getTime() - Date.now();
|
|
83
|
-
}
|
|
84
|
-
throw err_1;
|
|
85
|
-
case 3: return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}); };
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
export var autoAdjustClockskewMiddlewareOptions = {
|
|
92
|
-
step: 'finalizeRequest',
|
|
93
|
-
name: 'autoAdjustClockskewMiddleware',
|
|
94
|
-
};
|
|
95
|
-
export var prefixMiddlewareOptions = {
|
|
96
|
-
step: 'initialize',
|
|
97
|
-
name: 'addPrefixMiddleware',
|
|
98
|
-
};
|
|
99
81
|
export var credentialsProvider = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
82
|
var credentials, cred, error_1;
|
|
101
83
|
return __generator(this, function (_a) {
|
|
@@ -118,32 +100,34 @@ export var credentialsProvider = function () { return __awaiter(void 0, void 0,
|
|
|
118
100
|
}
|
|
119
101
|
});
|
|
120
102
|
}); };
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
103
|
+
/**
|
|
104
|
+
* A function that persists the s3 configs, so we don't need to
|
|
105
|
+
* assign each config parameter for every s3 API call.
|
|
106
|
+
*
|
|
107
|
+
* @inernal
|
|
108
|
+
*/
|
|
109
|
+
export var loadS3Config = function (config) {
|
|
110
|
+
if (!config.region) {
|
|
111
|
+
// Same error thrown by aws-sdk
|
|
112
|
+
throw new Error('Region is missing.');
|
|
131
113
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
credentials: credentialsProvider, customUserAgent: getAmplifyUserAgentObject({
|
|
114
|
+
return __assign(__assign(__assign({}, config), { region: config.region, credentials: config.credentials
|
|
115
|
+
? function () { return Promise.resolve(config.credentials); }
|
|
116
|
+
: credentialsProvider, userAgentValue: getAmplifyUserAgent({
|
|
136
117
|
category: Category.Storage,
|
|
137
|
-
action: storageAction,
|
|
138
|
-
}) }
|
|
139
|
-
|
|
140
|
-
|
|
118
|
+
action: config.storageAction,
|
|
119
|
+
}) }), (config.dangerouslyConnectToHttpEndpointForTesting
|
|
120
|
+
? {
|
|
121
|
+
customEndpoint: localTestingStorageEndpoint,
|
|
122
|
+
forcePathStyle: true,
|
|
123
|
+
}
|
|
124
|
+
: {}));
|
|
141
125
|
};
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
export var DEFAULT_PART_SIZE = 5 *
|
|
146
|
-
export var MAX_OBJECT_SIZE = 5 *
|
|
126
|
+
var MiB = 1024 * 1024;
|
|
127
|
+
var GiB = 1024 * MiB;
|
|
128
|
+
var TiB = 1024 * GiB;
|
|
129
|
+
export var DEFAULT_PART_SIZE = 5 * MiB;
|
|
130
|
+
export var MAX_OBJECT_SIZE = 5 * TiB;
|
|
147
131
|
export var MAX_PARTS_COUNT = 10000;
|
|
148
132
|
export var DEFAULT_QUEUE_SIZE = 4;
|
|
149
133
|
export var calculatePartSize = function (totalSize) {
|
|
@@ -155,4 +139,3 @@ export var calculatePartSize = function (totalSize) {
|
|
|
155
139
|
}
|
|
156
140
|
return partSize;
|
|
157
141
|
};
|
|
158
|
-
//# sourceMappingURL=S3ClientUtils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
export var AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
|
|
2
4
|
? Symbol.for('amplify_default')
|
|
3
5
|
: '@@amplify_default');
|
|
4
|
-
export var SET_CONTENT_LENGTH_HEADER = 'contentLengthMiddleware';
|
|
5
6
|
export var localTestingStorageEndpoint = 'http://localhost:20005';
|
|
6
7
|
export var UPLOADS_STORAGE_KEY = '__uploadInProgress';
|
|
7
|
-
//# sourceMappingURL=StorageConstants.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
export var StorageErrorStrings;
|
|
2
4
|
(function (StorageErrorStrings) {
|
|
3
5
|
StorageErrorStrings["NO_CREDENTIALS"] = "No credentials";
|
|
@@ -17,4 +19,3 @@ export var AWSS3ProviderUploadErrorStrings;
|
|
|
17
19
|
(function (AWSS3ProviderUploadErrorStrings) {
|
|
18
20
|
AWSS3ProviderUploadErrorStrings["UPLOAD_PAUSED_MESSAGE"] = "paused";
|
|
19
21
|
})(AWSS3ProviderUploadErrorStrings || (AWSS3ProviderUploadErrorStrings = {}));
|
|
20
|
-
//# sourceMappingURL=StorageErrorStrings.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
import { Hub } from '@aws-amplify/core';
|
|
2
4
|
import { AMPLIFY_SYMBOL } from './StorageConstants';
|
|
3
5
|
export var byteLength = function (x) {
|
|
@@ -36,4 +38,3 @@ export var isBlob = function (x) {
|
|
|
36
38
|
var isArrayBuffer = function (x) {
|
|
37
39
|
return typeof x !== 'undefined' && x instanceof ArrayBuffer;
|
|
38
40
|
};
|
|
39
|
-
//# sourceMappingURL=StorageUtils.js.map
|