@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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { PutObjectInput } from '../AwsClients/S3';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
4
|
export declare interface Part {
|
|
5
5
|
bodyPart: any;
|
|
6
6
|
partNumber: number;
|
|
7
|
-
emitter:
|
|
7
|
+
emitter: EventEmitter;
|
|
8
8
|
etag?: string;
|
|
9
9
|
_lastUploadedBytes: number;
|
|
10
10
|
}
|
|
@@ -13,14 +13,14 @@ export declare class AWSS3ProviderManagedUpload {
|
|
|
13
13
|
private params;
|
|
14
14
|
private opts;
|
|
15
15
|
private completedParts;
|
|
16
|
-
private
|
|
16
|
+
private s3Config;
|
|
17
17
|
private uploadId;
|
|
18
18
|
private partSize;
|
|
19
19
|
private bytesUploaded;
|
|
20
20
|
private totalBytesToUpload;
|
|
21
21
|
private emitter;
|
|
22
|
-
constructor(params:
|
|
23
|
-
upload(): Promise<string | import("
|
|
22
|
+
constructor(params: PutObjectInput, opts: any, emitter: EventEmitter);
|
|
23
|
+
upload(): Promise<string | import("../AwsClients/S3").PutObjectOutput>;
|
|
24
24
|
private createParts;
|
|
25
25
|
private createMultiPartUpload;
|
|
26
26
|
/**
|
|
@@ -36,5 +36,5 @@ export declare class AWSS3ProviderManagedUpload {
|
|
|
36
36
|
private byteLength;
|
|
37
37
|
private validateAndSanitizeBody;
|
|
38
38
|
private isGenericObject;
|
|
39
|
-
|
|
39
|
+
private getObjectKeyWithPrefix;
|
|
40
40
|
}
|
|
@@ -1,11 +1,57 @@
|
|
|
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 { calculatePartSize, DEFAULT_PART_SIZE, DEFAULT_QUEUE_SIZE, MAX_OBJECT_SIZE, loadS3Config, getPrefix, credentialsProvider, } from '../common/S3ClientUtils';
|
|
9
55
|
var logger = new Logger('AWSS3ProviderManagedUpload');
|
|
10
56
|
var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
11
57
|
function AWSS3ProviderManagedUpload(params, opts, emitter) {
|
|
@@ -19,66 +65,71 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
19
65
|
this.params = params;
|
|
20
66
|
this.opts = opts;
|
|
21
67
|
this.emitter = emitter;
|
|
22
|
-
this.
|
|
68
|
+
this.s3Config = loadS3Config(__assign(__assign({}, opts), { emitter: emitter, storageAction: StorageAction.Put }));
|
|
23
69
|
}
|
|
24
70
|
AWSS3ProviderManagedUpload.prototype.upload = function () {
|
|
25
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
26
|
-
var
|
|
72
|
+
var _a, _b, _c, _d, numberOfPartsToUpload, parts, start, error_1;
|
|
73
|
+
var _e;
|
|
27
74
|
var _this = this;
|
|
28
|
-
return __generator(this, function (
|
|
29
|
-
switch (
|
|
75
|
+
return __generator(this, function (_f) {
|
|
76
|
+
switch (_f.label) {
|
|
30
77
|
case 0:
|
|
31
|
-
|
|
78
|
+
_f.trys.push([0, 10, , 12]);
|
|
32
79
|
this.body = this.validateAndSanitizeBody(this.params.Body);
|
|
33
80
|
this.totalBytesToUpload = this.byteLength(this.body);
|
|
34
|
-
if (!(this.totalBytesToUpload <= DEFAULT_PART_SIZE)) return [3 /*break*/,
|
|
81
|
+
if (!(this.totalBytesToUpload <= DEFAULT_PART_SIZE)) return [3 /*break*/, 2];
|
|
35
82
|
// Multipart upload is not required. Upload the sanitized body as is
|
|
36
83
|
this.params.Body = this.body;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
84
|
+
_a = putObject;
|
|
85
|
+
_b = [this.s3Config];
|
|
86
|
+
_c = [__assign({}, this.params)];
|
|
87
|
+
_e = {};
|
|
88
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
89
|
+
case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_e.Key = _f.sent(), _e)]))]))];
|
|
90
|
+
case 2:
|
|
40
91
|
// Step 1: Determine appropriate part size.
|
|
41
92
|
this.partSize = calculatePartSize(this.totalBytesToUpload);
|
|
42
93
|
// Step 2: Initiate the multi part upload
|
|
43
|
-
|
|
94
|
+
_d = this;
|
|
44
95
|
return [4 /*yield*/, this.createMultiPartUpload()];
|
|
45
|
-
case
|
|
96
|
+
case 3:
|
|
46
97
|
// Step 2: Initiate the multi part upload
|
|
47
|
-
|
|
98
|
+
_d.uploadId = _f.sent();
|
|
48
99
|
numberOfPartsToUpload = Math.ceil(this.totalBytesToUpload / this.partSize);
|
|
49
100
|
parts = this.createParts();
|
|
50
101
|
start = 0;
|
|
51
|
-
|
|
52
|
-
case 3:
|
|
53
|
-
if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 6];
|
|
54
|
-
// Upload as many as `queueSize` parts simultaneously
|
|
55
|
-
return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + DEFAULT_QUEUE_SIZE))];
|
|
102
|
+
_f.label = 4;
|
|
56
103
|
case 4:
|
|
104
|
+
if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 7];
|
|
57
105
|
// Upload as many as `queueSize` parts simultaneously
|
|
58
|
-
|
|
59
|
-
_b.label = 5;
|
|
106
|
+
return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + DEFAULT_QUEUE_SIZE))];
|
|
60
107
|
case 5:
|
|
61
|
-
|
|
62
|
-
|
|
108
|
+
// Upload as many as `queueSize` parts simultaneously
|
|
109
|
+
_f.sent();
|
|
110
|
+
_f.label = 6;
|
|
63
111
|
case 6:
|
|
112
|
+
start += DEFAULT_QUEUE_SIZE;
|
|
113
|
+
return [3 /*break*/, 4];
|
|
114
|
+
case 7:
|
|
64
115
|
parts.map(function (part) {
|
|
65
116
|
_this.removeEventListener(part);
|
|
66
117
|
});
|
|
67
118
|
return [4 /*yield*/, this.finishMultiPartUpload(this.uploadId)];
|
|
68
|
-
case
|
|
119
|
+
case 8:
|
|
69
120
|
// Step 3: Finalize the upload such that S3 can recreate the file
|
|
70
|
-
return [2 /*return*/,
|
|
71
|
-
case
|
|
72
|
-
case
|
|
73
|
-
error_1 =
|
|
121
|
+
return [2 /*return*/, _f.sent()];
|
|
122
|
+
case 9: return [3 /*break*/, 12];
|
|
123
|
+
case 10:
|
|
124
|
+
error_1 = _f.sent();
|
|
74
125
|
// if any error is thrown, call cleanup
|
|
75
126
|
return [4 /*yield*/, this.cleanup(this.uploadId)];
|
|
76
|
-
case
|
|
127
|
+
case 11:
|
|
77
128
|
// if any error is thrown, call cleanup
|
|
78
|
-
|
|
129
|
+
_f.sent();
|
|
79
130
|
logger.error('Error. Cancelling the multipart upload.');
|
|
80
131
|
throw error_1;
|
|
81
|
-
case
|
|
132
|
+
case 12: return [2 /*return*/];
|
|
82
133
|
}
|
|
83
134
|
});
|
|
84
135
|
});
|
|
@@ -91,7 +142,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
91
142
|
parts.push({
|
|
92
143
|
bodyPart: this.body.slice(bodyStart, bodyEnd),
|
|
93
144
|
partNumber: parts.length + 1,
|
|
94
|
-
emitter: new
|
|
145
|
+
emitter: new EventEmitter(),
|
|
95
146
|
_lastUploadedBytes: 0,
|
|
96
147
|
});
|
|
97
148
|
bodyStart += this.partSize;
|
|
@@ -105,22 +156,27 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
105
156
|
};
|
|
106
157
|
AWSS3ProviderManagedUpload.prototype.createMultiPartUpload = function () {
|
|
107
158
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
159
|
+
var response, _a, _b, _c, error_2;
|
|
160
|
+
var _d;
|
|
161
|
+
return __generator(this, function (_e) {
|
|
162
|
+
switch (_e.label) {
|
|
111
163
|
case 0:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
164
|
+
_e.trys.push([0, 3, , 4]);
|
|
165
|
+
_a = createMultipartUpload;
|
|
166
|
+
_b = [this.s3Config];
|
|
167
|
+
_c = [__assign({}, this.params)];
|
|
168
|
+
_d = {};
|
|
169
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
170
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_d.Key = _e.sent(), _d)]))]))];
|
|
171
|
+
case 2:
|
|
172
|
+
response = _e.sent();
|
|
117
173
|
logger.debug(response.UploadId);
|
|
118
174
|
return [2 /*return*/, response.UploadId];
|
|
119
|
-
case
|
|
120
|
-
error_2 =
|
|
175
|
+
case 3:
|
|
176
|
+
error_2 = _e.sent();
|
|
121
177
|
logger.error(error_2);
|
|
122
178
|
throw error_2;
|
|
123
|
-
case
|
|
179
|
+
case 4: return [2 /*return*/];
|
|
124
180
|
}
|
|
125
181
|
});
|
|
126
182
|
});
|
|
@@ -138,17 +194,29 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
138
194
|
case 0:
|
|
139
195
|
_a.trys.push([0, 2, , 3]);
|
|
140
196
|
return [4 /*yield*/, Promise.all(parts.map(function (part) { return __awaiter(_this, void 0, void 0, function () {
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
197
|
+
var _a, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, res, _b, _c;
|
|
198
|
+
var _d;
|
|
199
|
+
return __generator(this, function (_e) {
|
|
200
|
+
switch (_e.label) {
|
|
144
201
|
case 0:
|
|
145
202
|
this.setupEventListener(part);
|
|
146
|
-
options = { emitter: part.emitter };
|
|
147
203
|
_a = this.params, Key = _a.Key, Bucket = _a.Bucket, SSECustomerAlgorithm = _a.SSECustomerAlgorithm, SSECustomerKey = _a.SSECustomerKey, SSECustomerKeyMD5 = _a.SSECustomerKeyMD5;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
204
|
+
_b = uploadPart;
|
|
205
|
+
_c = [__assign(__assign({}, this.s3Config), { emitter: part.emitter })];
|
|
206
|
+
_d = {
|
|
207
|
+
PartNumber: part.partNumber,
|
|
208
|
+
Body: part.bodyPart,
|
|
209
|
+
UploadId: uploadId
|
|
210
|
+
};
|
|
211
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
212
|
+
case 1: return [4 /*yield*/, _b.apply(void 0, _c.concat([(_d.Key = _e.sent(),
|
|
213
|
+
_d.Bucket = Bucket,
|
|
214
|
+
_d.SSECustomerAlgorithm = SSECustomerAlgorithm,
|
|
215
|
+
_d.SSECustomerKey = SSECustomerKey,
|
|
216
|
+
_d.SSECustomerKeyMD5 = SSECustomerKeyMD5,
|
|
217
|
+
_d)]))];
|
|
218
|
+
case 2:
|
|
219
|
+
res = _e.sent();
|
|
152
220
|
return [2 /*return*/, res];
|
|
153
221
|
}
|
|
154
222
|
});
|
|
@@ -174,29 +242,32 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
174
242
|
};
|
|
175
243
|
AWSS3ProviderManagedUpload.prototype.finishMultiPartUpload = function (uploadId) {
|
|
176
244
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
var input,
|
|
178
|
-
|
|
179
|
-
|
|
245
|
+
var input, Key, error_4;
|
|
246
|
+
var _a;
|
|
247
|
+
return __generator(this, function (_b) {
|
|
248
|
+
switch (_b.label) {
|
|
180
249
|
case 0:
|
|
181
|
-
|
|
182
|
-
Bucket: this.params.Bucket
|
|
183
|
-
Key: this.params.Key,
|
|
184
|
-
UploadId: uploadId,
|
|
185
|
-
MultipartUpload: { Parts: this.completedParts },
|
|
250
|
+
_a = {
|
|
251
|
+
Bucket: this.params.Bucket
|
|
186
252
|
};
|
|
187
|
-
|
|
188
|
-
_a.label = 1;
|
|
253
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
189
254
|
case 1:
|
|
190
|
-
_a.
|
|
191
|
-
|
|
255
|
+
input = (_a.Key = _b.sent(),
|
|
256
|
+
_a.UploadId = uploadId,
|
|
257
|
+
_a.MultipartUpload = { Parts: this.completedParts },
|
|
258
|
+
_a);
|
|
259
|
+
_b.label = 2;
|
|
192
260
|
case 2:
|
|
193
|
-
|
|
194
|
-
return [
|
|
261
|
+
_b.trys.push([2, 4, , 5]);
|
|
262
|
+
return [4 /*yield*/, completeMultipartUpload(this.s3Config, input)];
|
|
195
263
|
case 3:
|
|
196
|
-
|
|
264
|
+
Key = (_b.sent()).Key;
|
|
265
|
+
return [2 /*return*/, Key];
|
|
266
|
+
case 4:
|
|
267
|
+
error_4 = _b.sent();
|
|
197
268
|
logger.error('Error happened while finishing the upload.');
|
|
198
269
|
throw error_4;
|
|
199
|
-
case
|
|
270
|
+
case 5: return [2 /*return*/];
|
|
200
271
|
}
|
|
201
272
|
});
|
|
202
273
|
});
|
|
@@ -204,8 +275,9 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
204
275
|
AWSS3ProviderManagedUpload.prototype.cleanup = function (uploadId) {
|
|
205
276
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
277
|
var input, data;
|
|
207
|
-
|
|
208
|
-
|
|
278
|
+
var _a;
|
|
279
|
+
return __generator(this, function (_b) {
|
|
280
|
+
switch (_b.label) {
|
|
209
281
|
case 0:
|
|
210
282
|
// Reset this's state
|
|
211
283
|
this.body = null;
|
|
@@ -216,17 +288,20 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
216
288
|
// This is a single part upload;
|
|
217
289
|
return [2 /*return*/];
|
|
218
290
|
}
|
|
219
|
-
|
|
220
|
-
Bucket: this.params.Bucket
|
|
221
|
-
Key: this.params.Key,
|
|
222
|
-
UploadId: uploadId,
|
|
291
|
+
_a = {
|
|
292
|
+
Bucket: this.params.Bucket
|
|
223
293
|
};
|
|
224
|
-
return [4 /*yield*/, this.
|
|
294
|
+
return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
|
|
225
295
|
case 1:
|
|
226
|
-
_a.sent()
|
|
227
|
-
|
|
296
|
+
input = (_a.Key = _b.sent(),
|
|
297
|
+
_a.UploadId = uploadId,
|
|
298
|
+
_a);
|
|
299
|
+
return [4 /*yield*/, abortMultipartUpload(this.s3Config, input)];
|
|
228
300
|
case 2:
|
|
229
|
-
|
|
301
|
+
_b.sent();
|
|
302
|
+
return [4 /*yield*/, listParts(this.s3Config, input)];
|
|
303
|
+
case 3:
|
|
304
|
+
data = _b.sent();
|
|
230
305
|
if (data && data.Parts && data.Parts.length > 0) {
|
|
231
306
|
throw new Error('Multipart upload clean up failed.');
|
|
232
307
|
}
|
|
@@ -288,7 +363,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
288
363
|
sanitizedBody = body;
|
|
289
364
|
} */
|
|
290
365
|
if (this.byteLength(sanitizedBody) > MAX_OBJECT_SIZE) {
|
|
291
|
-
throw new Error("File size bigger than S3 Object limit of 5TB, got "
|
|
366
|
+
throw new Error("File size bigger than S3 Object limit of 5TB, got ".concat(this.totalBytesToUpload, " Bytes"));
|
|
292
367
|
}
|
|
293
368
|
return sanitizedBody;
|
|
294
369
|
};
|
|
@@ -305,13 +380,23 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
|
|
|
305
380
|
}
|
|
306
381
|
return false;
|
|
307
382
|
};
|
|
308
|
-
AWSS3ProviderManagedUpload.prototype.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
383
|
+
AWSS3ProviderManagedUpload.prototype.getObjectKeyWithPrefix = function (keyWithoutPrefix) {
|
|
384
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
385
|
+
var _a, _b;
|
|
386
|
+
var _c;
|
|
387
|
+
return __generator(this, function (_d) {
|
|
388
|
+
switch (_d.label) {
|
|
389
|
+
case 0:
|
|
390
|
+
_a = getPrefix;
|
|
391
|
+
_b = [__assign({}, this.opts)];
|
|
392
|
+
_c = {};
|
|
393
|
+
return [4 /*yield*/, credentialsProvider()];
|
|
394
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, [__assign.apply(void 0, _b.concat([(_c.credentials = _d.sent(), _c)]))])];
|
|
395
|
+
case 2: return [2 /*return*/, ((_d.sent()) + keyWithoutPrefix)];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
313
399
|
};
|
|
314
400
|
return AWSS3ProviderManagedUpload;
|
|
315
401
|
}());
|
|
316
402
|
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;
|