@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
package/lib-esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput,
|
|
1
|
+
import { PutObjectInput } from '../AwsClients/S3';
|
|
2
|
+
import { StorageOptions, StorageProvider, S3ProviderGetConfig, S3ProviderGetOuput, S3ProviderPutConfig, S3ProviderRemoveConfig, S3ProviderListConfig, S3ProviderCopyConfig, S3ProviderCopyOutput, S3CopySource, S3CopyDestination, S3ProviderRemoveOutput, S3ProviderPutOutput, S3ProviderListOutput, S3ProviderGetPropertiesConfig, S3ProviderGetPropertiesOutput } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Provide storage methods to use AWS S3
|
|
5
5
|
*/
|
|
@@ -44,7 +44,7 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
44
44
|
*
|
|
45
45
|
* @param {string} key - key of the object
|
|
46
46
|
* @param {S3ProviderGetConfig} [config] - Optional configuration for the underlying S3 command
|
|
47
|
-
* @return {Promise<string |
|
|
47
|
+
* @return {Promise<string | GetObjectOutput>} - A promise resolves to Amazon S3 presigned URL or the
|
|
48
48
|
* GetObjectCommandOutput if download is set to true on success
|
|
49
49
|
*/
|
|
50
50
|
get<T extends S3ProviderGetConfig & StorageOptions>(key: string, config?: T): Promise<S3ProviderGetOuput<T>>;
|
|
@@ -65,7 +65,7 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
65
65
|
* @return an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on
|
|
66
66
|
* success.
|
|
67
67
|
*/
|
|
68
|
-
put<T extends S3ProviderPutConfig>(key: string, object:
|
|
68
|
+
put<T extends S3ProviderPutConfig>(key: string, object: PutObjectInput['Body'], config?: T): S3ProviderPutOutput<T>;
|
|
69
69
|
/**
|
|
70
70
|
* Remove the object for specified key
|
|
71
71
|
* @param {string} key - key of the object
|
|
@@ -85,8 +85,4 @@ export declare class AWSS3Provider implements StorageProvider {
|
|
|
85
85
|
private _ensureCredentials;
|
|
86
86
|
private _isWithCredentials;
|
|
87
87
|
private _prefix;
|
|
88
|
-
/**
|
|
89
|
-
* Creates an S3 client with new V3 aws sdk
|
|
90
|
-
*/
|
|
91
|
-
private _createNewS3Client;
|
|
92
88
|
}
|
|
@@ -1,15 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
2
73
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
74
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
75
|
import { ConsoleLogger as Logger, Credentials, StorageHelper, Hub, parseAWSExports, StorageAction, } from '@aws-amplify/core';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createRequest } from '@aws-sdk/util-create-request';
|
|
8
|
-
import { S3RequestPresigner } from '@aws-sdk/s3-request-presigner';
|
|
9
|
-
import { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, } from './axios-http-handler';
|
|
76
|
+
import { copyObject, getObject, getPresignedGetObjectUrl, headObject, deleteObject, listObjectsV2, SERVICE_NAME as S3_SERVICE_NAME, } from '../AwsClients/S3';
|
|
77
|
+
import { SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT, } from '../AwsClients/S3/utils';
|
|
10
78
|
import { StorageErrorStrings } from '../common/StorageErrorStrings';
|
|
11
79
|
import { dispatchStorageEvent } from '../common/StorageUtils';
|
|
12
|
-
import {
|
|
80
|
+
import { getPrefix, loadS3Config, } from '../common/S3ClientUtils';
|
|
13
81
|
import { AWSS3ProviderManagedUpload } from './AWSS3ProviderManagedUpload';
|
|
14
82
|
import { AWSS3UploadTask, TaskEvents } from './AWSS3UploadTask';
|
|
15
83
|
import { UPLOADS_STORAGE_KEY } from '../common/StorageConstants';
|
|
@@ -20,7 +88,7 @@ var DEFAULT_PRESIGN_EXPIRATION = 900;
|
|
|
20
88
|
/**
|
|
21
89
|
* Provide storage methods to use AWS S3
|
|
22
90
|
*/
|
|
23
|
-
var AWSS3Provider = /** @class */ (function () {
|
|
91
|
+
export var AWSS3Provider = /** @class */ (function () {
|
|
24
92
|
/**
|
|
25
93
|
* Initialize Storage with AWS configurations
|
|
26
94
|
* @param {Object} config - Configuration object for storage
|
|
@@ -66,8 +134,9 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
66
134
|
return this._config;
|
|
67
135
|
};
|
|
68
136
|
AWSS3Provider.prototype.startResumableUpload = function (addTaskInput, config) {
|
|
69
|
-
var
|
|
70
|
-
var
|
|
137
|
+
var _a;
|
|
138
|
+
var s3Config = addTaskInput.s3Config, emitter = addTaskInput.emitter, key = addTaskInput.key, file = addTaskInput.file, params = addTaskInput.params;
|
|
139
|
+
var progressCallback = config.progressCallback, completeCallback = config.completeCallback, errorCallback = config.errorCallback, track = (_a = config.track, _a === void 0 ? false : _a);
|
|
71
140
|
if (!(file instanceof Blob)) {
|
|
72
141
|
throw new Error(StorageErrorStrings.INVALID_BLOB);
|
|
73
142
|
}
|
|
@@ -107,18 +176,18 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
107
176
|
// when its doing a final check with _listSingleFile function
|
|
108
177
|
var prefixPromise = Credentials.get().then(function (credentials) {
|
|
109
178
|
var cred = Credentials.shear(credentials);
|
|
110
|
-
return getPrefix(__assign(__assign({}, config), { credentials: cred }));
|
|
179
|
+
return getPrefix(__assign(__assign({}, config), { level: addTaskInput.accessLevel, credentials: cred }));
|
|
111
180
|
});
|
|
112
181
|
var task = new AWSS3UploadTask({
|
|
113
|
-
|
|
182
|
+
s3Config: s3Config,
|
|
114
183
|
file: file,
|
|
115
184
|
emitter: emitter,
|
|
116
|
-
level:
|
|
185
|
+
level: addTaskInput.accessLevel,
|
|
117
186
|
storage: this._storage,
|
|
118
187
|
params: params,
|
|
119
188
|
prefixPromise: prefixPromise,
|
|
120
189
|
});
|
|
121
|
-
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'success' }, null, "Upload Task created successfully for "
|
|
190
|
+
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'success' }, null, "Upload Task created successfully for ".concat(key));
|
|
122
191
|
// automatically start the upload task
|
|
123
192
|
task.resume();
|
|
124
193
|
return task;
|
|
@@ -135,7 +204,8 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
135
204
|
*/
|
|
136
205
|
AWSS3Provider.prototype.copy = function (src, dest, config) {
|
|
137
206
|
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
-
var credentialsOK, opt, acl, bucket, cacheControl, expires, track, serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId,
|
|
207
|
+
var credentialsOK, opt, acl, bucket, cacheControl, expires, track, serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, srcLevel, srcIdentityId, srcKey, destLevel, destKey, srcPrefix, destPrefix, finalSrcKey, finalDestKey, params, error_1;
|
|
208
|
+
var _a, _b;
|
|
139
209
|
return __generator(this, function (_c) {
|
|
140
210
|
switch (_c.label) {
|
|
141
211
|
case 0: return [4 /*yield*/, this._ensureCredentials()];
|
|
@@ -146,8 +216,8 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
146
216
|
}
|
|
147
217
|
opt = Object.assign({}, this._config, config);
|
|
148
218
|
acl = opt.acl, bucket = opt.bucket, cacheControl = opt.cacheControl, expires = opt.expires, track = opt.track, serverSideEncryption = opt.serverSideEncryption, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, SSEKMSKeyId = opt.SSEKMSKeyId;
|
|
149
|
-
_a = src.level,
|
|
150
|
-
_b = dest.level,
|
|
219
|
+
srcLevel = (_a = src.level, _a === void 0 ? DEFAULT_STORAGE_LEVEL : _a), srcIdentityId = src.identityId, srcKey = src.key;
|
|
220
|
+
destLevel = (_b = dest.level, _b === void 0 ? DEFAULT_STORAGE_LEVEL : _b), destKey = dest.key;
|
|
151
221
|
if (!srcKey || typeof srcKey !== 'string') {
|
|
152
222
|
throw new Error(StorageErrorStrings.NO_SRC_KEY);
|
|
153
223
|
}
|
|
@@ -155,13 +225,13 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
155
225
|
throw new Error(StorageErrorStrings.NO_DEST_KEY);
|
|
156
226
|
}
|
|
157
227
|
if (srcLevel !== 'protected' && srcIdentityId) {
|
|
158
|
-
logger.warn("You may copy files from another user if the source level is \"protected\", currently it's "
|
|
228
|
+
logger.warn("You may copy files from another user if the source level is \"protected\", currently it's ".concat(srcLevel));
|
|
159
229
|
}
|
|
160
230
|
srcPrefix = this._prefix(__assign(__assign(__assign({}, opt), { level: srcLevel }), (srcIdentityId && { identityId: srcIdentityId })));
|
|
161
231
|
destPrefix = this._prefix(__assign(__assign({}, opt), { level: destLevel }));
|
|
162
|
-
finalSrcKey = bucket
|
|
163
|
-
finalDestKey = ""
|
|
164
|
-
logger.debug("copying "
|
|
232
|
+
finalSrcKey = "".concat(bucket, "/").concat(srcPrefix).concat(srcKey);
|
|
233
|
+
finalDestKey = "".concat(destPrefix).concat(destKey);
|
|
234
|
+
logger.debug("copying ".concat(finalSrcKey, " to ").concat(finalDestKey));
|
|
165
235
|
params = {
|
|
166
236
|
Bucket: bucket,
|
|
167
237
|
CopySource: finalSrcKey,
|
|
@@ -190,17 +260,16 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
190
260
|
}
|
|
191
261
|
if (acl)
|
|
192
262
|
params.ACL = acl;
|
|
193
|
-
s3 = this._createNewS3Client(opt, StorageAction.Copy);
|
|
194
263
|
_c.label = 2;
|
|
195
264
|
case 2:
|
|
196
265
|
_c.trys.push([2, 4, , 5]);
|
|
197
|
-
return [4 /*yield*/,
|
|
266
|
+
return [4 /*yield*/, copyObject(loadS3Config(__assign(__assign({}, opt), { storageAction: StorageAction.Copy })), params)];
|
|
198
267
|
case 3:
|
|
199
268
|
_c.sent();
|
|
200
269
|
dispatchStorageEvent(track, 'copy', {
|
|
201
270
|
method: 'copy',
|
|
202
271
|
result: 'success',
|
|
203
|
-
}, null, "Copy success from "
|
|
272
|
+
}, null, "Copy success from ".concat(srcKey, " to ").concat(destKey));
|
|
204
273
|
return [2 /*return*/, {
|
|
205
274
|
key: destKey,
|
|
206
275
|
}];
|
|
@@ -209,7 +278,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
209
278
|
dispatchStorageEvent(track, 'copy', {
|
|
210
279
|
method: 'copy',
|
|
211
280
|
result: 'failed',
|
|
212
|
-
}, null, "Copy failed from "
|
|
281
|
+
}, null, "Copy failed from ".concat(srcKey, " to ").concat(destKey));
|
|
213
282
|
throw error_1;
|
|
214
283
|
case 5: return [2 /*return*/];
|
|
215
284
|
}
|
|
@@ -219,21 +288,22 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
219
288
|
AWSS3Provider.prototype.get = function (key, config) {
|
|
220
289
|
var _a;
|
|
221
290
|
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
var credentialsOK, opt, bucket, download, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, expires, track, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, progressCallback,
|
|
223
|
-
|
|
224
|
-
|
|
291
|
+
var credentialsOK, opt, bucket, download, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, expires, track, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, progressCallback, validateObjectExistence, prefix, final_key, emitter, s3Config, params, response, error_2, error_3, url, _b, _c, error_4;
|
|
292
|
+
var _d, _e;
|
|
293
|
+
return __generator(this, function (_f) {
|
|
294
|
+
switch (_f.label) {
|
|
225
295
|
case 0: return [4 /*yield*/, this._ensureCredentials()];
|
|
226
296
|
case 1:
|
|
227
|
-
credentialsOK =
|
|
297
|
+
credentialsOK = _f.sent();
|
|
228
298
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
229
299
|
throw new Error(StorageErrorStrings.NO_CREDENTIALS);
|
|
230
300
|
}
|
|
231
301
|
opt = Object.assign({}, this._config, config);
|
|
232
|
-
bucket = opt.bucket, download = opt.download, cacheControl = opt.cacheControl, contentDisposition = opt.contentDisposition, contentEncoding = opt.contentEncoding, contentLanguage = opt.contentLanguage, contentType = opt.contentType, expires = opt.expires, track = opt.track, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, progressCallback = opt.progressCallback,
|
|
302
|
+
bucket = opt.bucket, download = opt.download, cacheControl = opt.cacheControl, contentDisposition = opt.contentDisposition, contentEncoding = opt.contentEncoding, contentLanguage = opt.contentLanguage, contentType = opt.contentType, expires = opt.expires, track = opt.track, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, progressCallback = opt.progressCallback, validateObjectExistence = (_d = opt.validateObjectExistence, _d === void 0 ? false : _d);
|
|
233
303
|
prefix = this._prefix(opt);
|
|
234
304
|
final_key = prefix + key;
|
|
235
305
|
emitter = new events.EventEmitter();
|
|
236
|
-
|
|
306
|
+
s3Config = loadS3Config(__assign(__assign({}, opt), { emitter: emitter, storageAction: StorageAction.Get }));
|
|
237
307
|
logger.debug('get ' + key + ' from ' + final_key);
|
|
238
308
|
params = {
|
|
239
309
|
Bucket: bucket,
|
|
@@ -260,10 +330,9 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
260
330
|
params.SSECustomerKeyMD5 = SSECustomerKeyMD5;
|
|
261
331
|
}
|
|
262
332
|
if (!(download === true)) return [3 /*break*/, 5];
|
|
263
|
-
|
|
264
|
-
_d.label = 2;
|
|
333
|
+
_f.label = 2;
|
|
265
334
|
case 2:
|
|
266
|
-
|
|
335
|
+
_f.trys.push([2, 4, , 5]);
|
|
267
336
|
if (progressCallback) {
|
|
268
337
|
if (typeof progressCallback === 'function') {
|
|
269
338
|
emitter.on(SEND_DOWNLOAD_PROGRESS_EVENT, function (progress) {
|
|
@@ -275,58 +344,54 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
275
344
|
typeof progressCallback);
|
|
276
345
|
}
|
|
277
346
|
}
|
|
278
|
-
return [4 /*yield*/,
|
|
347
|
+
return [4 /*yield*/, getObject(s3Config, params)];
|
|
279
348
|
case 3:
|
|
280
|
-
response =
|
|
349
|
+
response = _f.sent();
|
|
281
350
|
emitter.removeAllListeners(SEND_DOWNLOAD_PROGRESS_EVENT);
|
|
282
351
|
dispatchStorageEvent(track, 'download', { method: 'get', result: 'success' }, {
|
|
283
352
|
fileSize: Number(response.Body['size'] || response.Body['length']),
|
|
284
|
-
}, "Download success for "
|
|
353
|
+
}, "Download success for ".concat(key));
|
|
285
354
|
return [2 /*return*/, response];
|
|
286
355
|
case 4:
|
|
287
|
-
error_2 =
|
|
356
|
+
error_2 = _f.sent();
|
|
288
357
|
dispatchStorageEvent(track, 'download', {
|
|
289
358
|
method: 'get',
|
|
290
359
|
result: 'failed',
|
|
291
|
-
}, null, "Download failed with "
|
|
360
|
+
}, null, "Download failed with ".concat(error_2.message));
|
|
292
361
|
throw error_2;
|
|
293
362
|
case 5:
|
|
294
363
|
if (!validateObjectExistence) return [3 /*break*/, 9];
|
|
295
|
-
|
|
296
|
-
_d.label = 6;
|
|
364
|
+
_f.label = 6;
|
|
297
365
|
case 6:
|
|
298
|
-
|
|
299
|
-
return [4 /*yield*/,
|
|
366
|
+
_f.trys.push([6, 8, , 9]);
|
|
367
|
+
return [4 /*yield*/, headObject(s3Config, params)];
|
|
300
368
|
case 7:
|
|
301
|
-
|
|
369
|
+
_f.sent();
|
|
302
370
|
return [3 /*break*/, 9];
|
|
303
371
|
case 8:
|
|
304
|
-
error_3 =
|
|
372
|
+
error_3 = _f.sent();
|
|
305
373
|
if (((_a = error_3.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) === 404) {
|
|
306
374
|
dispatchStorageEvent(track, 'getSignedUrl', {
|
|
307
375
|
method: 'get',
|
|
308
376
|
result: 'failed',
|
|
309
|
-
}, null, key
|
|
377
|
+
}, null, "".concat(key, " not found"));
|
|
310
378
|
}
|
|
311
379
|
throw error_3;
|
|
312
380
|
case 9:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return [4 /*yield*/, signer.presign(request, {
|
|
320
|
-
expiresIn: expires || DEFAULT_PRESIGN_EXPIRATION,
|
|
321
|
-
})];
|
|
381
|
+
_f.trys.push([9, 12, , 13]);
|
|
382
|
+
_b = getPresignedGetObjectUrl;
|
|
383
|
+
_c = [__assign({}, s3Config)];
|
|
384
|
+
_e = { expiration: expires || DEFAULT_PRESIGN_EXPIRATION };
|
|
385
|
+
return [4 /*yield*/, s3Config.credentials()];
|
|
386
|
+
case 10: return [4 /*yield*/, _b.apply(void 0, [__assign.apply(void 0, _c.concat([(_e.credentials = _f.sent(), _e.signingRegion = s3Config.region, _e.signingService = S3_SERVICE_NAME, _e)])), params])];
|
|
322
387
|
case 11:
|
|
323
|
-
url =
|
|
324
|
-
dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'success' }, null, "Signed URL: "
|
|
388
|
+
url = _f.sent();
|
|
389
|
+
dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'success' }, null, "Signed URL: ".concat(url));
|
|
325
390
|
return [2 /*return*/, url];
|
|
326
391
|
case 12:
|
|
327
|
-
error_4 =
|
|
392
|
+
error_4 = _f.sent();
|
|
328
393
|
logger.warn('get signed url error', error_4);
|
|
329
|
-
dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'failed' }, null, "Could not get a signed URL for "
|
|
394
|
+
dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'failed' }, null, "Could not get a signed URL for ".concat(key));
|
|
330
395
|
throw error_4;
|
|
331
396
|
case 13: return [2 /*return*/];
|
|
332
397
|
}
|
|
@@ -344,7 +409,8 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
344
409
|
AWSS3Provider.prototype.getProperties = function (key, config) {
|
|
345
410
|
var _a;
|
|
346
411
|
return __awaiter(this, void 0, void 0, function () {
|
|
347
|
-
var credentialsOK, opt, bucket,
|
|
412
|
+
var credentialsOK, opt, bucket, track, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, prefix, final_key, s3Config, params, response, getPropertiesResponse, error_5;
|
|
413
|
+
var _b;
|
|
348
414
|
return __generator(this, function (_c) {
|
|
349
415
|
switch (_c.label) {
|
|
350
416
|
case 0: return [4 /*yield*/, this._ensureCredentials()];
|
|
@@ -354,12 +420,11 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
354
420
|
throw new Error(StorageErrorStrings.NO_CREDENTIALS);
|
|
355
421
|
}
|
|
356
422
|
opt = Object.assign({}, this._config, config);
|
|
357
|
-
bucket = opt.bucket, _b = opt.track,
|
|
423
|
+
bucket = opt.bucket, track = (_b = opt.track, _b === void 0 ? false : _b), SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5;
|
|
358
424
|
prefix = this._prefix(opt);
|
|
359
425
|
final_key = prefix + key;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
logger.debug("getProperties " + key + " from " + final_key);
|
|
426
|
+
logger.debug("getProperties ".concat(key, " from ").concat(final_key));
|
|
427
|
+
s3Config = loadS3Config(__assign(__assign({}, opt), { storageAction: StorageAction.GetProperties }));
|
|
363
428
|
params = {
|
|
364
429
|
Bucket: bucket,
|
|
365
430
|
Key: final_key,
|
|
@@ -373,11 +438,10 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
373
438
|
if (SSECustomerKeyMD5) {
|
|
374
439
|
params.SSECustomerKeyMD5 = SSECustomerKeyMD5;
|
|
375
440
|
}
|
|
376
|
-
headObjectCommand = new HeadObjectCommand(params);
|
|
377
441
|
_c.label = 2;
|
|
378
442
|
case 2:
|
|
379
443
|
_c.trys.push([2, 4, , 5]);
|
|
380
|
-
return [4 /*yield*/,
|
|
444
|
+
return [4 /*yield*/, headObject(s3Config, params)];
|
|
381
445
|
case 3:
|
|
382
446
|
response = _c.sent();
|
|
383
447
|
getPropertiesResponse = {
|
|
@@ -387,7 +451,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
387
451
|
lastModified: response.LastModified,
|
|
388
452
|
metadata: response.Metadata,
|
|
389
453
|
};
|
|
390
|
-
dispatchStorageEvent(track, 'getProperties', { method: 'getProperties', result: 'success' }, null, "getProperties successful for "
|
|
454
|
+
dispatchStorageEvent(track, 'getProperties', { method: 'getProperties', result: 'success' }, null, "getProperties successful for ".concat(key));
|
|
391
455
|
return [2 /*return*/, getPropertiesResponse];
|
|
392
456
|
case 4:
|
|
393
457
|
error_5 = _c.sent();
|
|
@@ -395,7 +459,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
395
459
|
dispatchStorageEvent(track, 'getProperties', {
|
|
396
460
|
method: 'getProperties',
|
|
397
461
|
result: 'failed',
|
|
398
|
-
}, null, key
|
|
462
|
+
}, null, "".concat(key, " not found"));
|
|
399
463
|
}
|
|
400
464
|
throw error_5;
|
|
401
465
|
case 5: return [2 /*return*/];
|
|
@@ -462,14 +526,11 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
462
526
|
params.ACL = acl;
|
|
463
527
|
}
|
|
464
528
|
if (resumable === true) {
|
|
465
|
-
var
|
|
466
|
-
// we are using aws sdk middleware to inject the prefix to key, this way we don't have to call
|
|
467
|
-
// this._ensureCredentials() which allows us to make this function sync so we can return non-Promise like UploadTask
|
|
468
|
-
s3Client.middlewareStack.add(createPrefixMiddleware(opt, key), prefixMiddlewareOptions);
|
|
529
|
+
var s3Config = loadS3Config(__assign(__assign({}, opt), { storageAction: StorageAction.Put }));
|
|
469
530
|
var addTaskInput = {
|
|
470
531
|
bucket: bucket,
|
|
471
532
|
key: key,
|
|
472
|
-
|
|
533
|
+
s3Config: s3Config,
|
|
473
534
|
file: object,
|
|
474
535
|
emitter: emitter,
|
|
475
536
|
accessLevel: level,
|
|
@@ -492,13 +553,13 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
492
553
|
}
|
|
493
554
|
return uploader.upload().then(function (response) {
|
|
494
555
|
logger.debug('upload result', response);
|
|
495
|
-
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'success' }, null, "Upload success for "
|
|
556
|
+
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'success' }, null, "Upload success for ".concat(key));
|
|
496
557
|
return { key: key };
|
|
497
558
|
});
|
|
498
559
|
}
|
|
499
560
|
catch (error) {
|
|
500
561
|
logger.warn('error uploading', error);
|
|
501
|
-
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'failed' }, null, "Error uploading "
|
|
562
|
+
dispatchStorageEvent(track, 'upload', { method: 'put', result: 'failed' }, null, "Error uploading ".concat(key));
|
|
502
563
|
throw error;
|
|
503
564
|
}
|
|
504
565
|
};
|
|
@@ -510,7 +571,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
510
571
|
*/
|
|
511
572
|
AWSS3Provider.prototype.remove = function (key, config) {
|
|
512
573
|
return __awaiter(this, void 0, void 0, function () {
|
|
513
|
-
var credentialsOK, opt, bucket, track, prefix, final_key,
|
|
574
|
+
var credentialsOK, opt, bucket, track, prefix, final_key, params, s3Config, response, error_6;
|
|
514
575
|
return __generator(this, function (_a) {
|
|
515
576
|
switch (_a.label) {
|
|
516
577
|
case 0: return [4 /*yield*/, this._ensureCredentials()];
|
|
@@ -523,24 +584,23 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
523
584
|
bucket = opt.bucket, track = opt.track;
|
|
524
585
|
prefix = this._prefix(opt);
|
|
525
586
|
final_key = prefix + key;
|
|
526
|
-
s3 = this._createNewS3Client(opt, StorageAction.Remove);
|
|
527
587
|
logger.debug('remove ' + key + ' from ' + final_key);
|
|
528
588
|
params = {
|
|
529
589
|
Bucket: bucket,
|
|
530
590
|
Key: final_key,
|
|
531
591
|
};
|
|
532
|
-
|
|
592
|
+
s3Config = loadS3Config(__assign(__assign({}, opt), { storageAction: StorageAction.Remove }));
|
|
533
593
|
_a.label = 2;
|
|
534
594
|
case 2:
|
|
535
595
|
_a.trys.push([2, 4, , 5]);
|
|
536
|
-
return [4 /*yield*/,
|
|
596
|
+
return [4 /*yield*/, deleteObject(s3Config, params)];
|
|
537
597
|
case 3:
|
|
538
598
|
response = _a.sent();
|
|
539
|
-
dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'success' }, null, "Deleted "
|
|
599
|
+
dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'success' }, null, "Deleted ".concat(key, " successfully"));
|
|
540
600
|
return [2 /*return*/, response];
|
|
541
601
|
case 4:
|
|
542
602
|
error_6 = _a.sent();
|
|
543
|
-
dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'failed' }, null, "Deletion of "
|
|
603
|
+
dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'failed' }, null, "Deletion of ".concat(key, " failed with ").concat(error_6));
|
|
544
604
|
throw error_6;
|
|
545
605
|
case 5: return [2 /*return*/];
|
|
546
606
|
}
|
|
@@ -549,7 +609,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
549
609
|
};
|
|
550
610
|
AWSS3Provider.prototype._list = function (params, opt, prefix) {
|
|
551
611
|
return __awaiter(this, void 0, void 0, function () {
|
|
552
|
-
var list,
|
|
612
|
+
var list, response;
|
|
553
613
|
return __generator(this, function (_a) {
|
|
554
614
|
switch (_a.label) {
|
|
555
615
|
case 0:
|
|
@@ -557,9 +617,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
557
617
|
results: [],
|
|
558
618
|
hasNextToken: false,
|
|
559
619
|
};
|
|
560
|
-
|
|
561
|
-
listObjectsV2Command = new ListObjectsV2Command(__assign({}, params));
|
|
562
|
-
return [4 /*yield*/, s3.send(listObjectsV2Command)];
|
|
620
|
+
return [4 /*yield*/, listObjectsV2(loadS3Config(__assign(__assign({}, opt), { storageAction: StorageAction.List })), __assign({}, params))];
|
|
563
621
|
case 1:
|
|
564
622
|
response = _a.sent();
|
|
565
623
|
if (response && response.Contents) {
|
|
@@ -587,15 +645,14 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
587
645
|
* and file size for all objects in path
|
|
588
646
|
*/
|
|
589
647
|
AWSS3Provider.prototype.list = function (path, config) {
|
|
590
|
-
var _a;
|
|
591
648
|
return __awaiter(this, void 0, void 0, function () {
|
|
592
649
|
var credentialsOK, opt, bucket, track, pageSize, nextToken, prefix, final_path, list, MAX_PAGE_SIZE, listResult, params, error_7;
|
|
593
|
-
var
|
|
594
|
-
return __generator(this, function (
|
|
595
|
-
switch (
|
|
650
|
+
var _a, _b;
|
|
651
|
+
return __generator(this, function (_c) {
|
|
652
|
+
switch (_c.label) {
|
|
596
653
|
case 0: return [4 /*yield*/, this._ensureCredentials()];
|
|
597
654
|
case 1:
|
|
598
|
-
credentialsOK =
|
|
655
|
+
credentialsOK = _c.sent();
|
|
599
656
|
if (!credentialsOK || !this._isWithCredentials(this._config)) {
|
|
600
657
|
throw new Error(StorageErrorStrings.NO_CREDENTIALS);
|
|
601
658
|
}
|
|
@@ -604,9 +661,9 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
604
661
|
prefix = this._prefix(opt);
|
|
605
662
|
final_path = prefix + path;
|
|
606
663
|
logger.debug('list ' + path + ' from ' + final_path);
|
|
607
|
-
|
|
664
|
+
_c.label = 2;
|
|
608
665
|
case 2:
|
|
609
|
-
|
|
666
|
+
_c.trys.push([2, 10, , 11]);
|
|
610
667
|
list = {
|
|
611
668
|
results: [],
|
|
612
669
|
hasNextToken: false,
|
|
@@ -621,17 +678,17 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
621
678
|
};
|
|
622
679
|
params.ContinuationToken = nextToken;
|
|
623
680
|
if (!(pageSize === 'ALL')) return [3 /*break*/, 7];
|
|
624
|
-
|
|
681
|
+
_c.label = 3;
|
|
625
682
|
case 3: return [4 /*yield*/, this._list(params, opt, prefix)];
|
|
626
683
|
case 4:
|
|
627
|
-
listResult =
|
|
628
|
-
(
|
|
684
|
+
listResult = _c.sent();
|
|
685
|
+
(_a = list.results).push.apply(_a, __spreadArray([], __read(listResult.results), false));
|
|
629
686
|
if (listResult.nextToken)
|
|
630
687
|
params.ContinuationToken = listResult.nextToken;
|
|
631
|
-
|
|
688
|
+
_c.label = 5;
|
|
632
689
|
case 5:
|
|
633
690
|
if (listResult.nextToken) return [3 /*break*/, 3];
|
|
634
|
-
|
|
691
|
+
_c.label = 6;
|
|
635
692
|
case 6: return [3 /*break*/, 9];
|
|
636
693
|
case 7:
|
|
637
694
|
if (pageSize &&
|
|
@@ -639,22 +696,22 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
639
696
|
typeof pageSize === 'number')
|
|
640
697
|
params.MaxKeys = pageSize;
|
|
641
698
|
else
|
|
642
|
-
logger.warn("pageSize should be from 0 - "
|
|
699
|
+
logger.warn("pageSize should be from 0 - ".concat(MAX_PAGE_SIZE, "."));
|
|
643
700
|
return [4 /*yield*/, this._list(params, opt, prefix)];
|
|
644
701
|
case 8:
|
|
645
|
-
listResult =
|
|
646
|
-
(
|
|
702
|
+
listResult = _c.sent();
|
|
703
|
+
(_b = list.results).push.apply(_b, __spreadArray([], __read(listResult.results), false));
|
|
647
704
|
list.hasNextToken = listResult.hasNextToken;
|
|
648
|
-
list.nextToken =
|
|
649
|
-
|
|
705
|
+
list.nextToken = null !== null && null !== void 0 ? null : listResult.nextToken;
|
|
706
|
+
_c.label = 9;
|
|
650
707
|
case 9:
|
|
651
|
-
dispatchStorageEvent(track, 'list', { method: 'list', result: 'success' }, null, list.results.length
|
|
708
|
+
dispatchStorageEvent(track, 'list', { method: 'list', result: 'success' }, null, "".concat(list.results.length, " items returned from list operation"));
|
|
652
709
|
logger.debug('list', list);
|
|
653
710
|
return [2 /*return*/, list];
|
|
654
711
|
case 10:
|
|
655
|
-
error_7 =
|
|
712
|
+
error_7 = _c.sent();
|
|
656
713
|
logger.error('list InvalidArgument', error_7);
|
|
657
|
-
dispatchStorageEvent(track, 'list', { method: 'list', result: 'failed' }, null, "Listing items failed: "
|
|
714
|
+
dispatchStorageEvent(track, 'list', { method: 'list', result: 'failed' }, null, "Listing items failed: ".concat(error_7.message));
|
|
658
715
|
throw error_7;
|
|
659
716
|
case 11: return [2 /*return*/];
|
|
660
717
|
}
|
|
@@ -711,17 +768,7 @@ var AWSS3Provider = /** @class */ (function () {
|
|
|
711
768
|
return publicPath;
|
|
712
769
|
}
|
|
713
770
|
};
|
|
714
|
-
/**
|
|
715
|
-
* Creates an S3 client with new V3 aws sdk
|
|
716
|
-
*/
|
|
717
|
-
AWSS3Provider.prototype._createNewS3Client = function (config, storageAction, emitter) {
|
|
718
|
-
var s3client = createS3Client(config, storageAction, emitter);
|
|
719
|
-
s3client.middlewareStack.add(autoAdjustClockskewMiddleware(s3client.config), autoAdjustClockskewMiddlewareOptions);
|
|
720
|
-
return s3client;
|
|
721
|
-
};
|
|
722
771
|
AWSS3Provider.CATEGORY = 'Storage';
|
|
723
772
|
AWSS3Provider.PROVIDER_NAME = 'AWSS3';
|
|
724
773
|
return AWSS3Provider;
|
|
725
774
|
}());
|
|
726
|
-
export { AWSS3Provider };
|
|
727
|
-
//# sourceMappingURL=AWSS3Provider.js.map
|