@aws-amplify/storage 5.6.4-api-v6.2 → 5.6.4-api-v6.13
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 +0 -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 +1 -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/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,143 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
+
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;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
import { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
51
|
+
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
52
|
+
import { defaultConfig } from './base';
|
|
53
|
+
import { assignStringVariables, deserializeBoolean, deserializeNumber, deserializeTimestamp, emptyArrayGuard, map, parseXmlBody, parseXmlError, s3TransferHandler, } from './utils';
|
|
54
|
+
var listObjectsV2Serializer = function (input, endpoint) {
|
|
55
|
+
var headers = assignStringVariables({
|
|
56
|
+
'x-amz-request-payer': input.RequestPayer,
|
|
57
|
+
'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,
|
|
58
|
+
});
|
|
59
|
+
var query = assignStringVariables({
|
|
60
|
+
'list-type': '2',
|
|
61
|
+
'continuation-token': input.ContinuationToken,
|
|
62
|
+
delimiter: input.Delimiter,
|
|
63
|
+
'encoding-type': input.EncodingType,
|
|
64
|
+
'fetch-owner': input.FetchOwner,
|
|
65
|
+
'max-keys': input.MaxKeys,
|
|
66
|
+
prefix: input.Prefix,
|
|
67
|
+
'start-after': input.StartAfter,
|
|
68
|
+
});
|
|
69
|
+
var url = new URL(endpoint.url.toString());
|
|
70
|
+
url.search = new URLSearchParams(query).toString();
|
|
71
|
+
return {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: headers,
|
|
74
|
+
url: url,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var listObjectsV2Deserializer = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var error, parsed, contents;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
if (!(response.statusCode >= 300)) return [3 /*break*/, 2];
|
|
83
|
+
return [4 /*yield*/, parseXmlError(response)];
|
|
84
|
+
case 1:
|
|
85
|
+
error = _a.sent();
|
|
86
|
+
throw error;
|
|
87
|
+
case 2: return [4 /*yield*/, parseXmlBody(response)];
|
|
88
|
+
case 3:
|
|
89
|
+
parsed = _a.sent();
|
|
90
|
+
contents = map(parsed, {
|
|
91
|
+
CommonPrefixes: [
|
|
92
|
+
'CommonPrefixes',
|
|
93
|
+
function (value) { return emptyArrayGuard(value, deserializeCommonPrefixList); },
|
|
94
|
+
],
|
|
95
|
+
Contents: [
|
|
96
|
+
'Contents',
|
|
97
|
+
function (value) { return emptyArrayGuard(value, deserializeObjectList); },
|
|
98
|
+
],
|
|
99
|
+
ContinuationToken: 'ContinuationToken',
|
|
100
|
+
Delimiter: 'Delimiter',
|
|
101
|
+
EncodingType: 'EncodingType',
|
|
102
|
+
IsTruncated: ['IsTruncated', deserializeBoolean],
|
|
103
|
+
KeyCount: ['KeyCount', deserializeNumber],
|
|
104
|
+
MaxKeys: ['MaxKeys', deserializeNumber],
|
|
105
|
+
Name: 'Name',
|
|
106
|
+
NextContinuationToken: 'NextContinuationToken',
|
|
107
|
+
Prefix: 'Prefix',
|
|
108
|
+
StartAfter: 'StartAfter',
|
|
109
|
+
});
|
|
110
|
+
return [2 /*return*/, __assign({ $metadata: parseMetadata(response) }, contents)];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); };
|
|
114
|
+
var deserializeCommonPrefixList = function (output) {
|
|
115
|
+
return output.map(deserializeCommonPrefix);
|
|
116
|
+
};
|
|
117
|
+
var deserializeCommonPrefix = function (output) {
|
|
118
|
+
return map(output, {
|
|
119
|
+
Prefix: 'Prefix',
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var deserializeObjectList = function (output) { return output.map(deserializeObject); };
|
|
123
|
+
var deserializeObject = function (output) {
|
|
124
|
+
return map(output, {
|
|
125
|
+
Key: 'Key',
|
|
126
|
+
LastModified: ['LastModified', deserializeTimestamp],
|
|
127
|
+
ETag: 'ETag',
|
|
128
|
+
ChecksumAlgorithm: [
|
|
129
|
+
'ChecksumAlgorithm',
|
|
130
|
+
function (value) { return emptyArrayGuard(value, deserializeChecksumAlgorithmList); },
|
|
131
|
+
],
|
|
132
|
+
Size: ['Size', deserializeNumber],
|
|
133
|
+
StorageClass: 'StorageClass',
|
|
134
|
+
Owner: ['Owner', deserializeOwner],
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
var deserializeChecksumAlgorithmList = function (output) {
|
|
138
|
+
return output.map(function (entry) { return String(entry); });
|
|
139
|
+
};
|
|
140
|
+
var deserializeOwner = function (output) {
|
|
141
|
+
return map(output, { DisplayName: 'DisplayName', ID: 'ID' });
|
|
142
|
+
};
|
|
143
|
+
export var listObjectsV2 = composeServiceApi(s3TransferHandler, listObjectsV2Serializer, listObjectsV2Deserializer, __assign(__assign({}, defaultConfig), { responseType: 'text' }));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Endpoint, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
|
|
3
|
+
import type { ListPartsCommandInput, ListPartsCommandOutput } from './types';
|
|
4
|
+
export type ListPartsInput = Pick<ListPartsCommandInput, 'Bucket' | 'Key' | 'UploadId' | 'SSECustomerAlgorithm' | 'SSECustomerKey' | 'SSECustomerKeyMD5'>;
|
|
5
|
+
export type ListPartsOutput = Pick<ListPartsCommandOutput, 'Parts' | 'UploadId' | '$metadata'>;
|
|
6
|
+
export declare const listParts: (config: Omit<import("@aws-amplify/core/internals/aws-client-utils").UserAgentOptions & import("@aws-amplify/core/internals/aws-client-utils").RetryOptions<HttpResponse> & import("@aws-amplify/core/internals/aws-client-utils").SigningOptions & import("./runtime/xhrTransferHandler").XhrTransferHandlerOptions & import("@aws-amplify/core/internals/aws-client-utils").ServiceClientOptions & Partial<import("@aws-amplify/core/internals/aws-client-utils").UserAgentOptions & import("@aws-amplify/core/internals/aws-client-utils").RetryOptions<HttpResponse> & import("@aws-amplify/core/internals/aws-client-utils").SigningOptions & import("./runtime/xhrTransferHandler").XhrTransferHandlerOptions & import("@aws-amplify/core/internals/aws-client-utils").ServiceClientOptions>, "region" | "maxAttempts" | "credentials" | "retryDecider" | "computeDelay" | "abortSignal" | "service" | "uriEscapePath" | "endpointResolver" | "emitter" | "responseType" | "userAgentHeader" | "userAgentValue"> & {
|
|
7
|
+
region?: string;
|
|
8
|
+
maxAttempts?: number;
|
|
9
|
+
credentials?: import("@aws-sdk/types/types/credentials").Credentials | (() => Promise<import("@aws-sdk/types/types/credentials").Credentials>);
|
|
10
|
+
retryDecider?: (response?: HttpResponse, error?: unknown) => Promise<boolean>;
|
|
11
|
+
computeDelay?: (attempt: number) => number;
|
|
12
|
+
abortSignal?: AbortSignal;
|
|
13
|
+
service?: string;
|
|
14
|
+
uriEscapePath?: boolean;
|
|
15
|
+
endpointResolver?: (options: import("@aws-amplify/core/internals/aws-client-utils").EndpointResolverOptions, input?: any) => Endpoint;
|
|
16
|
+
emitter?: import("events").EventEmitter;
|
|
17
|
+
responseType?: "blob" | "text";
|
|
18
|
+
userAgentHeader?: string;
|
|
19
|
+
userAgentValue?: string;
|
|
20
|
+
}, input: ListPartsInput) => Promise<ListPartsOutput>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
+
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;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
import { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
51
|
+
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
52
|
+
import { defaultConfig } from './base';
|
|
53
|
+
import { emptyArrayGuard, serializeObjectSsecOptionsToHeaders, map, parseXmlBody, parseXmlError, s3TransferHandler, deserializeNumber, serializePathnameObjectKey, } from './utils';
|
|
54
|
+
var listPartsSerializer = function (input, endpoint) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var headers, url;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0: return [4 /*yield*/, serializeObjectSsecOptionsToHeaders(input)];
|
|
59
|
+
case 1:
|
|
60
|
+
headers = _a.sent();
|
|
61
|
+
url = new URL(endpoint.url.toString());
|
|
62
|
+
url.pathname = serializePathnameObjectKey(url, input.Key);
|
|
63
|
+
url.search = new URLSearchParams({
|
|
64
|
+
uploadId: input.UploadId,
|
|
65
|
+
}).toString();
|
|
66
|
+
return [2 /*return*/, {
|
|
67
|
+
method: 'GET',
|
|
68
|
+
headers: headers,
|
|
69
|
+
url: url,
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}); };
|
|
74
|
+
var listPartsDeserializer = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var error, parsed, contents;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
if (!(response.statusCode >= 300)) return [3 /*break*/, 2];
|
|
80
|
+
return [4 /*yield*/, parseXmlError(response)];
|
|
81
|
+
case 1:
|
|
82
|
+
error = _a.sent();
|
|
83
|
+
throw error;
|
|
84
|
+
case 2: return [4 /*yield*/, parseXmlBody(response)];
|
|
85
|
+
case 3:
|
|
86
|
+
parsed = _a.sent();
|
|
87
|
+
contents = map(parsed, {
|
|
88
|
+
UploadId: 'UploadId',
|
|
89
|
+
Parts: [
|
|
90
|
+
'Part',
|
|
91
|
+
function (value) { return emptyArrayGuard(value, deserializeCompletedPartList); },
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
return [2 /*return*/, __assign({ $metadata: parseMetadata(response) }, contents)];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}); };
|
|
98
|
+
var deserializeCompletedPartList = function (input) {
|
|
99
|
+
return input.map(function (item) {
|
|
100
|
+
return map(item, {
|
|
101
|
+
PartNumber: ['PartNumber', deserializeNumber],
|
|
102
|
+
ETag: 'ETag',
|
|
103
|
+
Size: ['Size', deserializeNumber],
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export var listParts = composeServiceApi(s3TransferHandler, listPartsSerializer, listPartsDeserializer, __assign(__assign({}, defaultConfig), { responseType: 'text' }));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Endpoint, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
|
|
3
|
+
import type { PutObjectCommandInput, PutObjectCommandOutput } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Reference: {@link S3ProviderPutConfig}
|
|
6
|
+
*/
|
|
7
|
+
export type PutObjectInput = Pick<PutObjectCommandInput, 'Bucket' | 'Key' | 'Body' | 'ServerSideEncryption' | 'SSECustomerAlgorithm' | 'SSECustomerKey' | 'SSECustomerKeyMD5' | 'SSEKMSKeyId' | 'ACL' | 'CacheControl' | 'ContentDisposition' | 'ContentEncoding' | 'ContentType' | 'Expires' | 'Metadata' | 'Tagging'>;
|
|
8
|
+
export type PutObjectOutput = Pick<PutObjectCommandOutput, '$metadata' | 'ETag' | 'VersionId'>;
|
|
9
|
+
export declare const putObject: (config: Omit<import("@aws-amplify/core/internals/aws-client-utils").UserAgentOptions & import("@aws-amplify/core/internals/aws-client-utils").RetryOptions<HttpResponse> & import("@aws-amplify/core/internals/aws-client-utils").SigningOptions & import("./runtime/xhrTransferHandler").XhrTransferHandlerOptions & import("@aws-amplify/core/internals/aws-client-utils").ServiceClientOptions & Partial<import("@aws-amplify/core/internals/aws-client-utils").UserAgentOptions & import("@aws-amplify/core/internals/aws-client-utils").RetryOptions<HttpResponse> & import("@aws-amplify/core/internals/aws-client-utils").SigningOptions & import("./runtime/xhrTransferHandler").XhrTransferHandlerOptions & import("@aws-amplify/core/internals/aws-client-utils").ServiceClientOptions>, "region" | "maxAttempts" | "credentials" | "retryDecider" | "computeDelay" | "abortSignal" | "service" | "uriEscapePath" | "endpointResolver" | "emitter" | "responseType" | "userAgentHeader" | "userAgentValue"> & {
|
|
10
|
+
region?: string;
|
|
11
|
+
maxAttempts?: number;
|
|
12
|
+
credentials?: import("@aws-sdk/types/types/credentials").Credentials | (() => Promise<import("@aws-sdk/types/types/credentials").Credentials>);
|
|
13
|
+
retryDecider?: (response?: HttpResponse, error?: unknown) => Promise<boolean>;
|
|
14
|
+
computeDelay?: (attempt: number) => number;
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
service?: string;
|
|
17
|
+
uriEscapePath?: boolean;
|
|
18
|
+
endpointResolver?: (options: import("@aws-amplify/core/internals/aws-client-utils").EndpointResolverOptions, input?: any) => Endpoint;
|
|
19
|
+
emitter?: import("events").EventEmitter;
|
|
20
|
+
responseType?: "blob" | "text";
|
|
21
|
+
userAgentHeader?: string;
|
|
22
|
+
userAgentValue?: string;
|
|
23
|
+
}, input: PutObjectInput) => Promise<PutObjectOutput>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
+
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;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
import { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
51
|
+
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
52
|
+
import { defaultConfig } from './base';
|
|
53
|
+
import { map, parseXmlError, s3TransferHandler, serializeObjectConfigsToHeaders, serializePathnameObjectKey, } from './utils';
|
|
54
|
+
var putObjectSerializer = function (input, endpoint) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var headers, url;
|
|
56
|
+
var _a;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, serializeObjectConfigsToHeaders(__assign(__assign({}, input), { ContentType: (_a = input.ContentType) !== null && _a !== void 0 ? _a : 'application/octet-stream' }))];
|
|
60
|
+
case 1:
|
|
61
|
+
headers = _b.sent();
|
|
62
|
+
url = new URL(endpoint.url.toString());
|
|
63
|
+
url.pathname = serializePathnameObjectKey(url, input.Key);
|
|
64
|
+
return [2 /*return*/, {
|
|
65
|
+
method: 'PUT',
|
|
66
|
+
headers: headers,
|
|
67
|
+
url: url,
|
|
68
|
+
body: input.Body,
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}); };
|
|
73
|
+
var putObjectDeserializer = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var error;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
if (!(response.statusCode >= 300)) return [3 /*break*/, 2];
|
|
79
|
+
return [4 /*yield*/, parseXmlError(response)];
|
|
80
|
+
case 1:
|
|
81
|
+
error = _a.sent();
|
|
82
|
+
throw error;
|
|
83
|
+
case 2: return [2 /*return*/, __assign(__assign({}, map(response.headers, {
|
|
84
|
+
ETag: 'etag',
|
|
85
|
+
VersionId: 'x-amz-version-id',
|
|
86
|
+
})), { $metadata: parseMetadata(response) })];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); };
|
|
90
|
+
export var putObject = composeServiceApi(s3TransferHandler, putObjectSerializer, putObjectDeserializer, __assign(__assign({}, defaultConfig), { responseType: 'text' }));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
function bytesToBase64(bytes) {
|
|
4
|
+
var base64Str = Array.from(bytes, function (x) { return String.fromCodePoint(x); }).join('');
|
|
5
|
+
return btoa(base64Str);
|
|
6
|
+
}
|
|
7
|
+
export function utf8Encode(input) {
|
|
8
|
+
return new TextEncoder().encode(input);
|
|
9
|
+
}
|
|
10
|
+
export function toBase64(input) {
|
|
11
|
+
if (typeof input === 'string') {
|
|
12
|
+
return bytesToBase64(utf8Encode(input));
|
|
13
|
+
}
|
|
14
|
+
return bytesToBase64(new Uint8Array(input.buffer, input.byteOffset, input.byteLength));
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
export function utf8Encode(input) {
|
|
5
|
+
return Buffer.from(input, 'utf-8');
|
|
6
|
+
}
|
|
7
|
+
export function toBase64(input) {
|
|
8
|
+
if (typeof input === 'string') {
|
|
9
|
+
return Buffer.from(input, 'utf-8').toString('base64');
|
|
10
|
+
}
|
|
11
|
+
return new Buffer(input.buffer).toString('base64');
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SEND_UPLOAD_PROGRESS_EVENT = "sendUploadProgress";
|
|
2
|
+
export declare const SEND_DOWNLOAD_PROGRESS_EVENT = "sendDownloadProgress";
|
|
3
|
+
export declare const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
4
|
+
export declare const NETWORK_ERROR_CODE = "ECONNABORTED";
|
|
5
|
+
export declare const ABORT_ERROR_MESSAGE = "Request aborted";
|
|
6
|
+
export declare const ABORT_ERROR_CODE = "ERR_ABORTED";
|
|
7
|
+
export declare const CANCELED_ERROR_MESSAGE = "canceled";
|
|
8
|
+
export declare const CANCELED_ERROR_CODE = "ERR_CANCELED";
|
|
9
|
+
export declare const CONTENT_SHA256_HEADER = "x-amz-content-sha256";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export var SEND_UPLOAD_PROGRESS_EVENT = 'sendUploadProgress';
|
|
4
|
+
export var SEND_DOWNLOAD_PROGRESS_EVENT = 'sendDownloadProgress';
|
|
5
|
+
export var NETWORK_ERROR_MESSAGE = 'Network Error';
|
|
6
|
+
export var NETWORK_ERROR_CODE = 'ECONNABORTED';
|
|
7
|
+
export var ABORT_ERROR_MESSAGE = 'Request aborted';
|
|
8
|
+
export var ABORT_ERROR_CODE = 'ERR_ABORTED';
|
|
9
|
+
export var CANCELED_ERROR_MESSAGE = 'canceled';
|
|
10
|
+
export var CANCELED_ERROR_CODE = 'ERR_CANCELED';
|
|
11
|
+
export var CONTENT_SHA256_HEADER = 'x-amz-content-sha256';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HttpRequest, MiddlewareHandler, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
|
|
2
|
+
/**
|
|
3
|
+
* A middleware that adds the x-amz-content-sha256 header to the request if it is not already present.
|
|
4
|
+
* It's required for S3 requests in browsers where the request body is sent in 1 chunk.
|
|
5
|
+
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const contentSha256Middleware: (options: {}) => (next: MiddlewareHandler<HttpRequest, HttpResponse>) => (request: HttpRequest) => Promise<HttpResponse>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
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;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
import { getHashedPayload, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
40
|
+
import { CONTENT_SHA256_HEADER } from './constants';
|
|
41
|
+
/**
|
|
42
|
+
* A middleware that adds the x-amz-content-sha256 header to the request if it is not already present.
|
|
43
|
+
* It's required for S3 requests in browsers where the request body is sent in 1 chunk.
|
|
44
|
+
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export var contentSha256Middleware = function (options) { return function (next) {
|
|
49
|
+
return function contentSha256Middleware(request) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var hash;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
if (!request.headers[CONTENT_SHA256_HEADER]) return [3 /*break*/, 1];
|
|
56
|
+
return [2 /*return*/, next(request)];
|
|
57
|
+
case 1: return [4 /*yield*/, getHashedPayload(request.body)];
|
|
58
|
+
case 2:
|
|
59
|
+
hash = _a.sent();
|
|
60
|
+
request.headers[CONTENT_SHA256_HEADER] = hash;
|
|
61
|
+
return [2 /*return*/, next(request)];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
}; };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
2
|
+
export { s3TransferHandler } from './s3TransferHandler/xhr';
|
|
3
|
+
export { parser } from './xmlParser/dom';
|
|
4
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
5
|
+
export { toBase64, utf8Encode } from './base64/index.browser';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Entry point for browser-specific S3 client utilities. It's used where DOMParser is available.
|
|
4
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
5
|
+
export { s3TransferHandler } from './s3TransferHandler/xhr';
|
|
6
|
+
export { parser } from './xmlParser/dom';
|
|
7
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
8
|
+
export { toBase64, utf8Encode } from './base64/index.browser';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
2
|
+
export { s3TransferHandler } from './s3TransferHandler/fetch';
|
|
3
|
+
export { parser } from './xmlParser/pureJs';
|
|
4
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
5
|
+
export { toBase64, utf8Encode } from './index.native';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Entry point for Node.js-specific S3 client utilities
|
|
4
|
+
// This behavior is not guaranteed in v5.
|
|
5
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
6
|
+
export { s3TransferHandler } from './s3TransferHandler/fetch';
|
|
7
|
+
export { parser } from './xmlParser/pureJs';
|
|
8
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
9
|
+
export { toBase64, utf8Encode } from './index.native';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
2
|
+
export { s3TransferHandler } from './s3TransferHandler/xhr';
|
|
3
|
+
export { parser } from './xmlParser/pureJs';
|
|
4
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
5
|
+
export { toBase64, utf8Encode } from './base64/index.native';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Entry point for ReactNative-specific S3 client utilities
|
|
4
|
+
export { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, CANCELED_ERROR_MESSAGE, CONTENT_SHA256_HEADER, } from './constants';
|
|
5
|
+
export { s3TransferHandler } from './s3TransferHandler/xhr';
|
|
6
|
+
export { parser } from './xmlParser/pureJs';
|
|
7
|
+
export { isCancelError } from './xhrTransferHandler';
|
|
8
|
+
export { toBase64, utf8Encode } from './base64/index.native';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { s3TransferHandler as s3BrowserTransferhandler } from './xhr';
|
|
2
|
+
/**
|
|
3
|
+
* S3 transfer handler for node based on Node-fetch. On top of basic transfer handler, it also supports
|
|
4
|
+
* x-amz-content-sha256 header. However, it does not support request&response process tracking like browser.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const s3TransferHandler: typeof s3BrowserTransferhandler;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { authenticatedHandler, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
4
|
+
import { composeTransferHandler } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
5
|
+
import { contentSha256Middleware } from '../contentSha256middleware';
|
|
6
|
+
/**
|
|
7
|
+
* S3 transfer handler for node based on Node-fetch. On top of basic transfer handler, it also supports
|
|
8
|
+
* x-amz-content-sha256 header. However, it does not support request&response process tracking like browser.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export var s3TransferHandler = composeTransferHandler(authenticatedHandler, [contentSha256Middleware]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RetryOptions, SigningOptions, UserAgentOptions, HttpRequest, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
|
|
2
|
+
/**
|
|
3
|
+
* S3 transfer handler for browser and React Native based on XHR. On top of basic transfer handler, it also supports
|
|
4
|
+
* x-amz-content-sha256 header, and request&response process tracking.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const s3TransferHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & SigningOptions & import("../xhrTransferHandler").XhrTransferHandlerOptions) => Promise<HttpResponse>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { retryMiddleware, signingMiddleware, userAgentMiddleware, } from '@aws-amplify/core/internals/aws-client-utils';
|
|
4
|
+
import { composeTransferHandler } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
5
|
+
import { contentSha256Middleware } from '../contentSha256middleware';
|
|
6
|
+
import { xhrTransferHandler } from '../xhrTransferHandler';
|
|
7
|
+
/**
|
|
8
|
+
* S3 transfer handler for browser and React Native based on XHR. On top of basic transfer handler, it also supports
|
|
9
|
+
* x-amz-content-sha256 header, and request&response process tracking.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export var s3TransferHandler = composeTransferHandler(xhrTransferHandler, [
|
|
14
|
+
contentSha256Middleware,
|
|
15
|
+
userAgentMiddleware,
|
|
16
|
+
retryMiddleware,
|
|
17
|
+
signingMiddleware,
|
|
18
|
+
]);
|