@aws-amplify/storage 5.6.4-api-v6.2 → 5.6.4-api-v6.23
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 +95 -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 +98 -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 +61 -31
- package/lib/common/MD5utils.d.ts +1 -0
- package/lib/common/MD5utils.js +79 -0
- package/lib/common/MD5utils.native.d.ts +1 -0
- package/lib/common/MD5utils.native.js +83 -0
- 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 +205 -99
- 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 +92 -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 +95 -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 +54 -25
- package/lib-esm/common/MD5utils.d.ts +1 -0
- package/lib-esm/common/MD5utils.js +75 -0
- package/lib-esm/common/MD5utils.native.d.ts +1 -0
- package/lib-esm/common/MD5utils.native.js +79 -0
- 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 +193 -88
- 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 +99 -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 +88 -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 +31 -27
- package/src/common/MD5utils.native.ts +38 -0
- package/src/common/MD5utils.ts +33 -0
- 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 +74 -64
- 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
|
@@ -1,11 +1,58 @@
|
|
|
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 __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
|
+
};
|
|
4
50
|
import { ConsoleLogger as Logger, StorageAction } from '@aws-amplify/core';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
51
|
+
import { putObject, createMultipartUpload, uploadPart, completeMultipartUpload, abortMultipartUpload, listParts, } from '../AwsClients/S3';
|
|
52
|
+
import { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, } from '../AwsClients/S3/utils';
|
|
53
|
+
import { EventEmitter } from 'events';
|
|
54
|
+
import { calculateContentMd5 } from '../common/MD5utils';
|
|
55
|
+
import { calculatePartSize, DEFAULT_PART_SIZE, DEFAULT_QUEUE_SIZE, MAX_OBJECT_SIZE, loadS3Config, getPrefix, credentialsProvider, } from '../common/S3ClientUtils';
|
|
9
56
|
var logger = new Logger('AWSS3ProviderManagedUpload');
|
|
10
57
|
var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
11
58
|
function AWSS3ProviderManagedUpload(params, opts, emitter) {
|
|
@@ -17,68 +64,83 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
17
64
|
this.totalBytesToUpload = 0;
|
|
18
65
|
this.emitter = null;
|
|
19
66
|
this.params = params;
|
|
20
|
-
this.opts = opts;
|
|
67
|
+
this.opts = __assign({ isObjectLockEnabled: false }, opts);
|
|
21
68
|
this.emitter = emitter;
|
|
22
|
-
this.
|
|
69
|
+
this.s3Config = loadS3Config(__assign(__assign({}, opts), { emitter: emitter, storageAction: StorageAction.Put }));
|
|
23
70
|
}
|
|
24
71
|
AWSS3ProviderManagedUpload.prototype.upload = function () {
|
|
25
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
26
|
-
var
|
|
73
|
+
var isObjectLockEnabled, _a, _b, _c, _d, _e, numberOfPartsToUpload, parts, start, error_1;
|
|
74
|
+
var _f;
|
|
27
75
|
var _this = this;
|
|
28
|
-
return __generator(this, function (
|
|
29
|
-
switch (
|
|
76
|
+
return __generator(this, function (_g) {
|
|
77
|
+
switch (_g.label) {
|
|
30
78
|
case 0:
|
|
31
|
-
|
|
79
|
+
_g.trys.push([0, 12, , 14]);
|
|
80
|
+
isObjectLockEnabled = this.opts.isObjectLockEnabled;
|
|
81
|
+
if (!(isObjectLockEnabled === true)) return [3 /*break*/, 2];
|
|
82
|
+
_a = this.params;
|
|
83
|
+
return [4 /*yield*/, calculateContentMd5(
|
|
84
|
+
// @ts-expect-error currently ReadableStream<any> is not being supported in put api
|
|
85
|
+
this.params.Body)];
|
|
86
|
+
case 1:
|
|
87
|
+
_a.ContentMD5 = _g.sent();
|
|
88
|
+
_g.label = 2;
|
|
89
|
+
case 2:
|
|
32
90
|
this.body = this.validateAndSanitizeBody(this.params.Body);
|
|
33
91
|
this.totalBytesToUpload = this.byteLength(this.body);
|
|
34
|
-
if (!(this.totalBytesToUpload <= DEFAULT_PART_SIZE)) return [3 /*break*/,
|
|
92
|
+
if (!(this.totalBytesToUpload <= DEFAULT_PART_SIZE)) return [3 /*break*/, 4];
|
|
35
93
|
// Multipart upload is not required. Upload the sanitized body as is
|
|
36
94
|
this.params.Body = this.body;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
95
|
+
_b = putObject;
|
|
96
|
+
_c = [this.s3Config];
|
|
97
|
+
_d = [__assign({}, this.params)];
|
|
98
|
+
_f = {};
|
|
99
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
100
|
+
case 3: return [2 /*return*/, _b.apply(void 0, _c.concat([__assign.apply(void 0, _d.concat([(_f.Key = _g.sent(), _f)]))]))];
|
|
101
|
+
case 4:
|
|
40
102
|
// Step 1: Determine appropriate part size.
|
|
41
103
|
this.partSize = calculatePartSize(this.totalBytesToUpload);
|
|
42
104
|
// Step 2: Initiate the multi part upload
|
|
43
|
-
|
|
105
|
+
_e = this;
|
|
44
106
|
return [4 /*yield*/, this.createMultiPartUpload()];
|
|
45
|
-
case
|
|
107
|
+
case 5:
|
|
46
108
|
// Step 2: Initiate the multi part upload
|
|
47
|
-
|
|
109
|
+
_e.uploadId = _g.sent();
|
|
48
110
|
numberOfPartsToUpload = Math.ceil(this.totalBytesToUpload / this.partSize);
|
|
49
111
|
parts = this.createParts();
|
|
50
112
|
start = 0;
|
|
51
|
-
|
|
52
|
-
case
|
|
53
|
-
if (!(start < numberOfPartsToUpload)) return [3 /*break*/,
|
|
113
|
+
_g.label = 6;
|
|
114
|
+
case 6:
|
|
115
|
+
if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 9];
|
|
54
116
|
// Upload as many as `queueSize` parts simultaneously
|
|
55
117
|
return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + DEFAULT_QUEUE_SIZE))];
|
|
56
|
-
case
|
|
118
|
+
case 7:
|
|
57
119
|
// Upload as many as `queueSize` parts simultaneously
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
case
|
|
120
|
+
_g.sent();
|
|
121
|
+
_g.label = 8;
|
|
122
|
+
case 8:
|
|
61
123
|
start += DEFAULT_QUEUE_SIZE;
|
|
62
|
-
return [3 /*break*/,
|
|
63
|
-
case
|
|
124
|
+
return [3 /*break*/, 6];
|
|
125
|
+
case 9:
|
|
64
126
|
parts.map(function (part) {
|
|
65
127
|
_this.removeEventListener(part);
|
|
66
128
|
});
|
|
67
129
|
return [4 /*yield*/, this.finishMultiPartUpload(this.uploadId)];
|
|
68
|
-
case
|
|
130
|
+
case 10:
|
|
69
131
|
// Step 3: Finalize the upload such that S3 can recreate the file
|
|
70
|
-
return [2 /*return*/,
|
|
71
|
-
case
|
|
72
|
-
case
|
|
73
|
-
error_1 =
|
|
132
|
+
return [2 /*return*/, _g.sent()];
|
|
133
|
+
case 11: return [3 /*break*/, 14];
|
|
134
|
+
case 12:
|
|
135
|
+
error_1 = _g.sent();
|
|
74
136
|
// if any error is thrown, call cleanup
|
|
75
137
|
return [4 /*yield*/, this.cleanup(this.uploadId)];
|
|
76
|
-
case
|
|
138
|
+
case 13:
|
|
77
139
|
// if any error is thrown, call cleanup
|
|
78
|
-
|
|
140
|
+
_g.sent();
|
|
79
141
|
logger.error('Error. Cancelling the multipart upload.');
|
|
80
142
|
throw error_1;
|
|
81
|
-
case
|
|
143
|
+
case 14: return [2 /*return*/];
|
|
82
144
|
}
|
|
83
145
|
});
|
|
84
146
|
});
|
|
@@ -91,7 +153,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
91
153
|
parts.push({
|
|
92
154
|
bodyPart: this.body.slice(bodyStart, bodyEnd),
|
|
93
155
|
partNumber: parts.length + 1,
|
|
94
|
-
emitter: new
|
|
156
|
+
emitter: new EventEmitter(),
|
|
95
157
|
_lastUploadedBytes: 0,
|
|
96
158
|
});
|
|
97
159
|
bodyStart += this.partSize;
|
|
@@ -105,22 +167,27 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
105
167
|
};
|
|
106
168
|
AWSS3ProviderManagedUpload.prototype.createMultiPartUpload = function () {
|
|
107
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
170
|
+
var response, _a, _b, _c, error_2;
|
|
171
|
+
var _d;
|
|
172
|
+
return __generator(this, function (_e) {
|
|
173
|
+
switch (_e.label) {
|
|
111
174
|
case 0:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
175
|
+
_e.trys.push([0, 3, , 4]);
|
|
176
|
+
_a = createMultipartUpload;
|
|
177
|
+
_b = [this.s3Config];
|
|
178
|
+
_c = [__assign({}, this.params)];
|
|
179
|
+
_d = {};
|
|
180
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
181
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_d.Key = _e.sent(), _d)]))]))];
|
|
182
|
+
case 2:
|
|
183
|
+
response = _e.sent();
|
|
117
184
|
logger.debug(response.UploadId);
|
|
118
185
|
return [2 /*return*/, response.UploadId];
|
|
119
|
-
case
|
|
120
|
-
error_2 =
|
|
186
|
+
case 3:
|
|
187
|
+
error_2 = _e.sent();
|
|
121
188
|
logger.error(error_2);
|
|
122
189
|
throw error_2;
|
|
123
|
-
case
|
|
190
|
+
case 4: return [2 /*return*/];
|
|
124
191
|
}
|
|
125
192
|
});
|
|
126
193
|
});
|
|
@@ -138,17 +205,38 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
138
205
|
case 0:
|
|
139
206
|
_a.trys.push([0, 2, , 3]);
|
|
140
207
|
return [4 /*yield*/, Promise.all(parts.map(function (part) { return __awaiter(_this, void 0, void 0, function () {
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
208
|
+
var isObjectLockEnabled, _a, _b, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, ContentMD5, res, _c, _d;
|
|
209
|
+
var _e;
|
|
210
|
+
return __generator(this, function (_f) {
|
|
211
|
+
switch (_f.label) {
|
|
144
212
|
case 0:
|
|
145
213
|
this.setupEventListener(part);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
214
|
+
isObjectLockEnabled = this.opts.isObjectLockEnabled;
|
|
215
|
+
if (!isObjectLockEnabled) return [3 /*break*/, 2];
|
|
216
|
+
_a = this.params;
|
|
217
|
+
return [4 /*yield*/, calculateContentMd5(part.bodyPart)];
|
|
150
218
|
case 1:
|
|
151
|
-
|
|
219
|
+
_a.ContentMD5 = _f.sent();
|
|
220
|
+
_f.label = 2;
|
|
221
|
+
case 2:
|
|
222
|
+
_b = this.params, Key = _b.Key, Bucket = _b.Bucket, SSECustomerAlgorithm = _b.SSECustomerAlgorithm, SSECustomerKey = _b.SSECustomerKey, SSECustomerKeyMD5 = _b.SSECustomerKeyMD5, ContentMD5 = _b.ContentMD5;
|
|
223
|
+
_c = uploadPart;
|
|
224
|
+
_d = [__assign(__assign({}, this.s3Config), { emitter: part.emitter })];
|
|
225
|
+
_e = {
|
|
226
|
+
PartNumber: part.partNumber,
|
|
227
|
+
Body: part.bodyPart,
|
|
228
|
+
UploadId: uploadId
|
|
229
|
+
};
|
|
230
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
231
|
+
case 3: return [4 /*yield*/, _c.apply(void 0, _d.concat([(_e.Key = _f.sent(),
|
|
232
|
+
_e.Bucket = Bucket,
|
|
233
|
+
_e.SSECustomerAlgorithm = SSECustomerAlgorithm,
|
|
234
|
+
_e.SSECustomerKey = SSECustomerKey,
|
|
235
|
+
_e.SSECustomerKeyMD5 = SSECustomerKeyMD5,
|
|
236
|
+
_e.ContentMD5 = ContentMD5,
|
|
237
|
+
_e)]))];
|
|
238
|
+
case 4:
|
|
239
|
+
res = _f.sent();
|
|
152
240
|
return [2 /*return*/, res];
|
|
153
241
|
}
|
|
154
242
|
});
|
|
@@ -174,29 +262,32 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
174
262
|
};
|
|
175
263
|
AWSS3ProviderManagedUpload.prototype.finishMultiPartUpload = function (uploadId) {
|
|
176
264
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
var input,
|
|
178
|
-
|
|
179
|
-
|
|
265
|
+
var input, Key, error_4;
|
|
266
|
+
var _a;
|
|
267
|
+
return __generator(this, function (_b) {
|
|
268
|
+
switch (_b.label) {
|
|
180
269
|
case 0:
|
|
181
|
-
|
|
182
|
-
Bucket: this.params.Bucket
|
|
183
|
-
Key: this.params.Key,
|
|
184
|
-
UploadId: uploadId,
|
|
185
|
-
MultipartUpload: { Parts: this.completedParts },
|
|
270
|
+
_a = {
|
|
271
|
+
Bucket: this.params.Bucket
|
|
186
272
|
};
|
|
187
|
-
|
|
188
|
-
_a.label = 1;
|
|
273
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
189
274
|
case 1:
|
|
190
|
-
_a.
|
|
191
|
-
|
|
275
|
+
input = (_a.Key = _b.sent(),
|
|
276
|
+
_a.UploadId = uploadId,
|
|
277
|
+
_a.MultipartUpload = { Parts: this.completedParts },
|
|
278
|
+
_a);
|
|
279
|
+
_b.label = 2;
|
|
192
280
|
case 2:
|
|
193
|
-
|
|
194
|
-
return [
|
|
281
|
+
_b.trys.push([2, 4, , 5]);
|
|
282
|
+
return [4 /*yield*/, completeMultipartUpload(this.s3Config, input)];
|
|
195
283
|
case 3:
|
|
196
|
-
|
|
284
|
+
Key = (_b.sent()).Key;
|
|
285
|
+
return [2 /*return*/, Key];
|
|
286
|
+
case 4:
|
|
287
|
+
error_4 = _b.sent();
|
|
197
288
|
logger.error('Error happened while finishing the upload.');
|
|
198
289
|
throw error_4;
|
|
199
|
-
case
|
|
290
|
+
case 5: return [2 /*return*/];
|
|
200
291
|
}
|
|
201
292
|
});
|
|
202
293
|
});
|
|
@@ -204,8 +295,9 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
204
295
|
AWSS3ProviderManagedUpload.prototype.cleanup = function (uploadId) {
|
|
205
296
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
297
|
var input, data;
|
|
207
|
-
|
|
208
|
-
|
|
298
|
+
var _a;
|
|
299
|
+
return __generator(this, function (_b) {
|
|
300
|
+
switch (_b.label) {
|
|
209
301
|
case 0:
|
|
210
302
|
// Reset this's state
|
|
211
303
|
this.body = null;
|
|
@@ -216,17 +308,20 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
216
308
|
// This is a single part upload;
|
|
217
309
|
return [2 /*return*/];
|
|
218
310
|
}
|
|
219
|
-
|
|
220
|
-
Bucket: this.params.Bucket
|
|
221
|
-
Key: this.params.Key,
|
|
222
|
-
UploadId: uploadId,
|
|
311
|
+
_a = {
|
|
312
|
+
Bucket: this.params.Bucket
|
|
223
313
|
};
|
|
224
|
-
return [4 /*yield*/, this.
|
|
314
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
225
315
|
case 1:
|
|
226
|
-
_a.sent()
|
|
227
|
-
|
|
316
|
+
input = (_a.Key = _b.sent(),
|
|
317
|
+
_a.UploadId = uploadId,
|
|
318
|
+
_a);
|
|
319
|
+
return [4 /*yield*/, abortMultipartUpload(this.s3Config, input)];
|
|
228
320
|
case 2:
|
|
229
|
-
|
|
321
|
+
_b.sent();
|
|
322
|
+
return [4 /*yield*/, listParts(this.s3Config, input)];
|
|
323
|
+
case 3:
|
|
324
|
+
data = _b.sent();
|
|
230
325
|
if (data && data.Parts && data.Parts.length > 0) {
|
|
231
326
|
throw new Error('Multipart upload clean up failed.');
|
|
232
327
|
}
|
|
@@ -288,7 +383,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
288
383
|
sanitizedBody = body;
|
|
289
384
|
} */
|
|
290
385
|
if (this.byteLength(sanitizedBody) > MAX_OBJECT_SIZE) {
|
|
291
|
-
throw new Error("File size bigger than S3 Object limit of 5TB, got "
|
|
386
|
+
throw new Error("File size bigger than S3 Object limit of 5TB, got ".concat(this.totalBytesToUpload, " Bytes"));
|
|
292
387
|
}
|
|
293
388
|
return sanitizedBody;
|
|
294
389
|
};
|
|
@@ -305,13 +400,23 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
305
400
|
}
|
|
306
401
|
return false;
|
|
307
402
|
};
|
|
308
|
-
AWSS3ProviderManagedUpload.prototype.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
403
|
+
AWSS3ProviderManagedUpload.prototype.getObjectKeyWithPrefix = function (keyWithoutPrefix) {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
+
var _a, _b;
|
|
406
|
+
var _c;
|
|
407
|
+
return __generator(this, function (_d) {
|
|
408
|
+
switch (_d.label) {
|
|
409
|
+
case 0:
|
|
410
|
+
_a = getPrefix;
|
|
411
|
+
_b = [__assign({}, this.opts)];
|
|
412
|
+
_c = {};
|
|
413
|
+
return [4 /*yield*/, credentialsProvider()];
|
|
414
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [__assign.apply(void 0, _b.concat([(_c.credentials = _d.sent(), _c)]))])];
|
|
415
|
+
case 2: return [2 /*return*/, ((_d.sent()) + keyWithoutPrefix)];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
});
|
|
313
419
|
};
|
|
314
420
|
return AWSS3ProviderManagedUpload;
|
|
315
421
|
}());
|
|
316
422
|
export { AWSS3ProviderManagedUpload };
|
|
317
|
-
//# sourceMappingURL=AWSS3ProviderManagedUpload.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { UploadPartCommandInput, S3Client, PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
3
2
|
import * as events from 'events';
|
|
4
|
-
import { Canceler } from 'axios';
|
|
5
3
|
import { UploadTask } from '../types/Provider';
|
|
4
|
+
import { PutObjectInput, UploadPartInput } from '../AwsClients/S3';
|
|
5
|
+
import { S3ResolvedConfig } from '../common/S3ClientUtils';
|
|
6
6
|
import { StorageAccessLevel } from '..';
|
|
7
7
|
export declare enum AWSS3UploadTaskState {
|
|
8
8
|
INIT = 0,
|
|
@@ -18,18 +18,18 @@ export declare enum TaskEvents {
|
|
|
18
18
|
ERROR = "error"
|
|
19
19
|
}
|
|
20
20
|
export interface AWSS3UploadTaskParams {
|
|
21
|
-
|
|
21
|
+
s3Config: S3ResolvedConfig;
|
|
22
22
|
file: Blob;
|
|
23
23
|
storage: Storage;
|
|
24
24
|
level: StorageAccessLevel;
|
|
25
|
-
params:
|
|
25
|
+
params: PutObjectInput;
|
|
26
26
|
prefixPromise: Promise<string>;
|
|
27
27
|
emitter?: events.EventEmitter;
|
|
28
28
|
}
|
|
29
29
|
export interface InProgressRequest {
|
|
30
|
-
uploadPartInput:
|
|
30
|
+
uploadPartInput: UploadPartInput;
|
|
31
31
|
s3Request: Promise<any>;
|
|
32
|
-
|
|
32
|
+
abortController: AbortController;
|
|
33
33
|
}
|
|
34
34
|
export interface UploadTaskCompleteEvent {
|
|
35
35
|
key?: string;
|
|
@@ -55,7 +55,7 @@ export declare class AWSS3UploadTask implements UploadTask {
|
|
|
55
55
|
private readonly emitter;
|
|
56
56
|
private readonly file;
|
|
57
57
|
private readonly queueSize;
|
|
58
|
-
private readonly
|
|
58
|
+
private readonly s3Config;
|
|
59
59
|
private readonly storage;
|
|
60
60
|
private readonly storageSync;
|
|
61
61
|
private readonly fileId;
|
|
@@ -69,7 +69,7 @@ export declare class AWSS3UploadTask implements UploadTask {
|
|
|
69
69
|
private totalBytes;
|
|
70
70
|
private uploadId;
|
|
71
71
|
state: AWSS3UploadTaskState;
|
|
72
|
-
constructor({
|
|
72
|
+
constructor({ s3Config, file, emitter, storage, params, level, prefixPromise, }: AWSS3UploadTaskParams);
|
|
73
73
|
get percent(): number;
|
|
74
74
|
get isInProgress(): boolean;
|
|
75
75
|
private _listSingleFile;
|