@aws-amplify/storage 6.4.7-storage-browser.3fc169e.0 → 6.4.7-storage-browser.084b4ff.0
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/dist/cjs/errors/types/validation.js +31 -0
- package/dist/cjs/errors/types/validation.js.map +1 -1
- package/dist/cjs/providers/s3/apis/downloadData.js +6 -1
- package/dist/cjs/providers/s3/apis/downloadData.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/copy.js +13 -3
- package/dist/cjs/providers/s3/apis/internal/copy.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/getProperties.js +5 -1
- package/dist/cjs/providers/s3/apis/internal/getProperties.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/getUrl.js +5 -1
- package/dist/cjs/providers/s3/apis/internal/getUrl.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/list.js +5 -1
- package/dist/cjs/providers/s3/apis/internal/list.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/remove.js +5 -1
- package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/types/index.js +6 -0
- package/dist/cjs/providers/s3/apis/internal/types/index.js.map +1 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData.js +49 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData.js.map +1 -0
- package/dist/cjs/providers/s3/apis/uploadData/index.js +5 -34
- package/dist/cjs/providers/s3/apis/uploadData/index.js.map +1 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadHandlers.js +7 -10
- package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadHandlers.js.map +1 -1
- package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js +7 -5
- package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js.map +1 -1
- package/dist/cjs/providers/s3/utils/config.js +47 -0
- package/dist/cjs/providers/s3/utils/config.js.map +1 -0
- package/dist/cjs/providers/s3/utils/index.js +3 -1
- package/dist/cjs/providers/s3/utils/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js +6 -21
- package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js.map +1 -1
- package/dist/cjs/storageBrowser/createLocationCredentialsHandler.js.map +1 -0
- package/dist/cjs/{storage-browser → storageBrowser}/index.js +5 -3
- package/dist/cjs/storageBrowser/index.js.map +1 -0
- package/dist/cjs/storageBrowser/listCallerAccessGrants.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/constants.js +9 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/constants.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/create.js +70 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/create.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/index.js +9 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/index.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/registry.js +58 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/registry.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/store.js +100 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/store.js.map +1 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/validators.js +59 -0
- package/dist/cjs/storageBrowser/locationCredentialsStore/validators.js.map +1 -0
- package/dist/cjs/storageBrowser/managedAuthAdapter.js +12 -0
- package/dist/cjs/storageBrowser/managedAuthAdapter.js.map +1 -0
- package/dist/cjs/storageBrowser/types.js.map +1 -0
- package/dist/esm/errors/types/validation.d.ts +8 -1
- package/dist/esm/errors/types/validation.mjs +31 -0
- package/dist/esm/errors/types/validation.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/downloadData.mjs +6 -1
- package/dist/esm/providers/s3/apis/downloadData.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/copy.mjs +14 -3
- package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs +6 -1
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs +6 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/list.mjs +6 -1
- package/dist/esm/providers/s3/apis/internal/list.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/remove.mjs +6 -1
- package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/types/index.d.ts +26 -0
- package/dist/esm/providers/s3/apis/internal/types/index.mjs +2 -0
- package/dist/esm/{storage-browser → providers/s3/apis/internal/types}/index.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData.d.ts +3 -0
- package/dist/esm/providers/s3/apis/internal/uploadData.mjs +54 -0
- package/dist/esm/providers/s3/apis/internal/uploadData.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/uploadData/index.mjs +5 -41
- package/dist/esm/providers/s3/apis/uploadData/index.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.d.ts +8 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.mjs +7 -10
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.d.ts +9 -1
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs +7 -5
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs.map +1 -1
- package/dist/esm/providers/s3/types/options.d.ts +18 -4
- package/dist/esm/providers/s3/utils/config.d.ts +8 -0
- package/dist/esm/providers/s3/utils/config.mjs +45 -0
- package/dist/esm/providers/s3/utils/config.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/index.d.ts +1 -0
- package/dist/esm/providers/s3/utils/index.mjs +1 -0
- package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.d.ts +7 -8
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs +6 -21
- package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs.map +1 -1
- package/dist/esm/storageBrowser/createLocationCredentialsHandler.mjs.map +1 -0
- package/dist/esm/{storage-browser → storageBrowser}/index.d.ts +2 -1
- package/dist/esm/{storage-browser → storageBrowser}/index.mjs +2 -1
- package/dist/esm/storageBrowser/index.mjs.map +1 -0
- package/dist/esm/storageBrowser/listCallerAccessGrants.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/constants.d.ts +2 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/constants.mjs +7 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/constants.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/create.mjs +68 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/create.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/index.d.ts +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/index.mjs +2 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/index.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/registry.d.ts +17 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/registry.mjs +54 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/registry.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/store.d.ts +36 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/store.mjs +96 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/store.mjs.map +1 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/validators.d.ts +9 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/validators.mjs +57 -0
- package/dist/esm/storageBrowser/locationCredentialsStore/validators.mjs.map +1 -0
- package/dist/esm/storageBrowser/managedAuthAdapter.d.ts +12 -0
- package/dist/esm/storageBrowser/managedAuthAdapter.mjs +9 -0
- package/dist/esm/storageBrowser/managedAuthAdapter.mjs.map +1 -0
- package/dist/esm/{storage-browser → storageBrowser}/types.d.ts +18 -22
- package/package.json +5 -5
- package/src/errors/types/validation.ts +32 -0
- package/src/providers/s3/apis/downloadData.ts +7 -1
- package/src/providers/s3/apis/internal/copy.ts +14 -8
- package/src/providers/s3/apis/internal/getProperties.ts +6 -1
- package/src/providers/s3/apis/internal/getUrl.ts +6 -1
- package/src/providers/s3/apis/internal/list.ts +7 -1
- package/src/providers/s3/apis/internal/remove.ts +6 -1
- package/src/providers/s3/apis/internal/types/index.ts +31 -0
- package/src/providers/s3/apis/internal/uploadData.ts +58 -0
- package/src/providers/s3/apis/uploadData/index.ts +6 -41
- package/src/providers/s3/apis/uploadData/multipart/uploadHandlers.ts +18 -10
- package/src/providers/s3/apis/uploadData/putObjectJob.ts +16 -9
- package/src/providers/s3/types/options.ts +20 -1
- package/src/providers/s3/utils/config.ts +59 -0
- package/src/providers/s3/utils/index.ts +1 -0
- package/src/providers/s3/utils/resolveS3ConfigAndInput.ts +20 -41
- package/src/{storage-browser → storageBrowser}/index.ts +5 -1
- package/src/storageBrowser/locationCredentialsStore/constants.ts +5 -0
- package/src/storageBrowser/locationCredentialsStore/create.ts +105 -0
- package/src/storageBrowser/locationCredentialsStore/index.ts +4 -0
- package/src/storageBrowser/locationCredentialsStore/registry.ts +82 -0
- package/src/storageBrowser/locationCredentialsStore/store.ts +162 -0
- package/src/storageBrowser/locationCredentialsStore/validators.ts +86 -0
- package/src/storageBrowser/managedAuthAdapter.ts +27 -0
- package/src/{storage-browser → storageBrowser}/types.ts +22 -21
- package/dist/cjs/storage-browser/createLocationCredentialsHandler.js.map +0 -1
- package/dist/cjs/storage-browser/index.js.map +0 -1
- package/dist/cjs/storage-browser/listCallerAccessGrants.js.map +0 -1
- package/dist/cjs/storage-browser/locationCredentialsStore/createLocationCredentialsStore.js +0 -13
- package/dist/cjs/storage-browser/locationCredentialsStore/createLocationCredentialsStore.js.map +0 -1
- package/dist/cjs/storage-browser/types.js.map +0 -1
- package/dist/esm/storage-browser/createLocationCredentialsHandler.mjs.map +0 -1
- package/dist/esm/storage-browser/listCallerAccessGrants.mjs.map +0 -1
- package/dist/esm/storage-browser/locationCredentialsStore/createLocationCredentialsStore.mjs +0 -10
- package/dist/esm/storage-browser/locationCredentialsStore/createLocationCredentialsStore.mjs.map +0 -1
- package/src/storage-browser/locationCredentialsStore/createLocationCredentialsStore.ts +0 -12
- /package/dist/cjs/{storage-browser → storageBrowser}/createLocationCredentialsHandler.js +0 -0
- /package/dist/cjs/{storage-browser → storageBrowser}/listCallerAccessGrants.js +0 -0
- /package/dist/cjs/{storage-browser → storageBrowser}/types.js +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/createLocationCredentialsHandler.d.ts +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/createLocationCredentialsHandler.mjs +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/listCallerAccessGrants.d.ts +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/listCallerAccessGrants.mjs +0 -0
- /package/dist/esm/{storage-browser/locationCredentialsStore/createLocationCredentialsStore.d.ts → storageBrowser/locationCredentialsStore/create.d.ts} +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/types.mjs +0 -0
- /package/dist/esm/{storage-browser → storageBrowser}/types.mjs.map +0 -0
- /package/src/{storage-browser → storageBrowser}/createLocationCredentialsHandler.ts +0 -0
- /package/src/{storage-browser → storageBrowser}/listCallerAccessGrants.ts +0 -0
|
@@ -21,7 +21,17 @@ var StorageValidationErrorCode;
|
|
|
21
21
|
StorageValidationErrorCode["InvalidUploadSource"] = "InvalidUploadSource";
|
|
22
22
|
StorageValidationErrorCode["ObjectIsTooLarge"] = "ObjectIsTooLarge";
|
|
23
23
|
StorageValidationErrorCode["UrlExpirationMaxLimitExceed"] = "UrlExpirationMaxLimitExceed";
|
|
24
|
+
StorageValidationErrorCode["InvalidLocationCredentialsCacheSize"] = "InvalidLocationCredentialsCacheSize";
|
|
25
|
+
StorageValidationErrorCode["LocationCredentialsStoreDestroyed"] = "LocationCredentialsStoreDestroyed";
|
|
26
|
+
StorageValidationErrorCode["LocationCredentialsBucketMismatch"] = "LocationCredentialsBucketMismatch";
|
|
27
|
+
StorageValidationErrorCode["LocationCredentialsCrossBucket"] = "LocationCredentialsCrossBucket";
|
|
28
|
+
StorageValidationErrorCode["LocationCredentialsPathMismatch"] = "LocationCredentialsPathMismatch";
|
|
29
|
+
StorageValidationErrorCode["LocationCredentialsPermissionMismatch"] = "LocationCredentialsPermissionMismatch";
|
|
30
|
+
StorageValidationErrorCode["InvalidS3Uri"] = "InvalidS3Uri";
|
|
24
31
|
})(StorageValidationErrorCode = exports.StorageValidationErrorCode || (exports.StorageValidationErrorCode = {}));
|
|
32
|
+
// Common error message strings to save some bytes
|
|
33
|
+
const LOCATION_SPECIFIC_CREDENTIALS = 'Location-specific credentials';
|
|
34
|
+
const DOES_NOT_MATCH = 'does not match that required for the API call';
|
|
25
35
|
exports.validationErrorMap = {
|
|
26
36
|
[StorageValidationErrorCode.NoCredentials]: {
|
|
27
37
|
message: 'Credentials should not be empty.',
|
|
@@ -68,5 +78,26 @@ exports.validationErrorMap = {
|
|
|
68
78
|
[StorageValidationErrorCode.InvalidStoragePathInput]: {
|
|
69
79
|
message: 'Input `path` does not allow a leading slash (/).',
|
|
70
80
|
},
|
|
81
|
+
[StorageValidationErrorCode.InvalidLocationCredentialsCacheSize]: {
|
|
82
|
+
message: 'locationCredentialsCacheSize must be a positive integer.',
|
|
83
|
+
},
|
|
84
|
+
[StorageValidationErrorCode.LocationCredentialsStoreDestroyed]: {
|
|
85
|
+
message: `${LOCATION_SPECIFIC_CREDENTIALS} store has been destroyed.`,
|
|
86
|
+
},
|
|
87
|
+
[StorageValidationErrorCode.InvalidS3Uri]: {
|
|
88
|
+
message: 'Invalid S3 URI.',
|
|
89
|
+
},
|
|
90
|
+
[StorageValidationErrorCode.LocationCredentialsCrossBucket]: {
|
|
91
|
+
message: `${LOCATION_SPECIFIC_CREDENTIALS} cannot be used across buckets.`,
|
|
92
|
+
},
|
|
93
|
+
[StorageValidationErrorCode.LocationCredentialsBucketMismatch]: {
|
|
94
|
+
message: `${LOCATION_SPECIFIC_CREDENTIALS} bucket ${DOES_NOT_MATCH}.`,
|
|
95
|
+
},
|
|
96
|
+
[StorageValidationErrorCode.LocationCredentialsPathMismatch]: {
|
|
97
|
+
message: `${LOCATION_SPECIFIC_CREDENTIALS} path ${DOES_NOT_MATCH}.`,
|
|
98
|
+
},
|
|
99
|
+
[StorageValidationErrorCode.LocationCredentialsPermissionMismatch]: {
|
|
100
|
+
message: `${LOCATION_SPECIFIC_CREDENTIALS} permission ${DOES_NOT_MATCH}.`,
|
|
101
|
+
},
|
|
71
102
|
};
|
|
72
103
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.StorageValidationErrorCode = void 0;\nvar StorageValidationErrorCode;\n(function (StorageValidationErrorCode) {\n StorageValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n StorageValidationErrorCode[\"NoIdentityId\"] = \"NoIdentityId\";\n StorageValidationErrorCode[\"NoKey\"] = \"NoKey\";\n StorageValidationErrorCode[\"NoSourceKey\"] = \"NoSourceKey\";\n StorageValidationErrorCode[\"NoDestinationKey\"] = \"NoDestinationKey\";\n StorageValidationErrorCode[\"NoSourcePath\"] = \"NoSourcePath\";\n StorageValidationErrorCode[\"NoDestinationPath\"] = \"NoDestinationPath\";\n StorageValidationErrorCode[\"NoBucket\"] = \"NoBucket\";\n StorageValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n StorageValidationErrorCode[\"InvalidStorageOperationPrefixInput\"] = \"InvalidStorageOperationPrefixInput\";\n StorageValidationErrorCode[\"InvalidStorageOperationInput\"] = \"InvalidStorageOperationInput\";\n StorageValidationErrorCode[\"InvalidStoragePathInput\"] = \"InvalidStoragePathInput\";\n StorageValidationErrorCode[\"InvalidUploadSource\"] = \"InvalidUploadSource\";\n StorageValidationErrorCode[\"ObjectIsTooLarge\"] = \"ObjectIsTooLarge\";\n StorageValidationErrorCode[\"UrlExpirationMaxLimitExceed\"] = \"UrlExpirationMaxLimitExceed\";\n})(StorageValidationErrorCode = exports.StorageValidationErrorCode || (exports.StorageValidationErrorCode = {}));\nexports.validationErrorMap = {\n [StorageValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [StorageValidationErrorCode.NoIdentityId]: {\n message: 'Missing identity ID when accessing objects in protected or private access level.',\n },\n [StorageValidationErrorCode.NoKey]: {\n message: 'Missing key in api call.',\n },\n [StorageValidationErrorCode.NoSourceKey]: {\n message: 'Missing source key in copy api call.',\n },\n [StorageValidationErrorCode.NoDestinationKey]: {\n message: 'Missing destination key in copy api call.',\n },\n [StorageValidationErrorCode.NoSourcePath]: {\n message: 'Missing source path in copy api call.',\n },\n [StorageValidationErrorCode.NoDestinationPath]: {\n message: 'Missing destination path in copy api call.',\n },\n [StorageValidationErrorCode.NoBucket]: {\n message: 'Missing bucket name while accessing object.',\n },\n [StorageValidationErrorCode.NoRegion]: {\n message: 'Missing region while accessing object.',\n },\n [StorageValidationErrorCode.UrlExpirationMaxLimitExceed]: {\n message: 'Url Expiration can not be greater than 7 Days.',\n },\n [StorageValidationErrorCode.ObjectIsTooLarge]: {\n message: 'Object size cannot not be greater than 5TB.',\n },\n [StorageValidationErrorCode.InvalidUploadSource]: {\n message: 'Upload source type can only be a `Blob`, `File`, `ArrayBuffer`, or `string`.',\n },\n [StorageValidationErrorCode.InvalidStorageOperationInput]: {\n message: 'Path or key parameter must be specified in the input. Both can not be specified at the same time.',\n },\n [StorageValidationErrorCode.InvalidStorageOperationPrefixInput]: {\n message: 'Both path and prefix can not be specified at the same time.',\n },\n [StorageValidationErrorCode.InvalidStoragePathInput]: {\n message: 'Input `path` does not allow a leading slash (/).',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AACzE,IAAI,0BAA0B,CAAC;AAC/B,CAAC,UAAU,0BAA0B,EAAE;AACvC,IAAI,0BAA0B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AAClE,IAAI,0BAA0B,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AAChE,IAAI,0BAA0B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAClD,IAAI,0BAA0B,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC;AAC9D,IAAI,0BAA0B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACxE,IAAI,0BAA0B,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AAChE,IAAI,0BAA0B,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC1E,IAAI,0BAA0B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACxD,IAAI,0BAA0B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACxD,IAAI,0BAA0B,CAAC,oCAAoC,CAAC,GAAG,oCAAoC,CAAC;AAC5G,IAAI,0BAA0B,CAAC,8BAA8B,CAAC,GAAG,8BAA8B,CAAC;AAChG,IAAI,0BAA0B,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AACtF,IAAI,0BAA0B,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AAC9E,IAAI,0BAA0B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACxE,IAAI,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BAAmB,GAAG;AACtD,QAAQ,OAAO,EAAE,8EAA8E;AAC/F,KAAK;AACL,IAAI,CAAC,0BAA0B,CAAC,4BAA4B,GAAG;AAC/D,QAAQ,OAAO,EAAE,mGAAmG;AACpH,KAAK;AACL,IAAI,CAAC,0BAA0B,CAAC,kCAAkC,GAAG;AACrE,QAAQ,OAAO,EAAE,6DAA6D;AAC9E,KAAK;AACL,IAAI,CAAC,0BAA0B,CAAC,uBAAuB,GAAG;AAC1D,QAAQ,OAAO,EAAE,kDAAkD;AACnE,KAAK;AACL,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.StorageValidationErrorCode = void 0;\nvar StorageValidationErrorCode;\n(function (StorageValidationErrorCode) {\n StorageValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n StorageValidationErrorCode[\"NoIdentityId\"] = \"NoIdentityId\";\n StorageValidationErrorCode[\"NoKey\"] = \"NoKey\";\n StorageValidationErrorCode[\"NoSourceKey\"] = \"NoSourceKey\";\n StorageValidationErrorCode[\"NoDestinationKey\"] = \"NoDestinationKey\";\n StorageValidationErrorCode[\"NoSourcePath\"] = \"NoSourcePath\";\n StorageValidationErrorCode[\"NoDestinationPath\"] = \"NoDestinationPath\";\n StorageValidationErrorCode[\"NoBucket\"] = \"NoBucket\";\n StorageValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n StorageValidationErrorCode[\"InvalidStorageOperationPrefixInput\"] = \"InvalidStorageOperationPrefixInput\";\n StorageValidationErrorCode[\"InvalidStorageOperationInput\"] = \"InvalidStorageOperationInput\";\n StorageValidationErrorCode[\"InvalidStoragePathInput\"] = \"InvalidStoragePathInput\";\n StorageValidationErrorCode[\"InvalidUploadSource\"] = \"InvalidUploadSource\";\n StorageValidationErrorCode[\"ObjectIsTooLarge\"] = \"ObjectIsTooLarge\";\n StorageValidationErrorCode[\"UrlExpirationMaxLimitExceed\"] = \"UrlExpirationMaxLimitExceed\";\n StorageValidationErrorCode[\"InvalidLocationCredentialsCacheSize\"] = \"InvalidLocationCredentialsCacheSize\";\n StorageValidationErrorCode[\"LocationCredentialsStoreDestroyed\"] = \"LocationCredentialsStoreDestroyed\";\n StorageValidationErrorCode[\"LocationCredentialsBucketMismatch\"] = \"LocationCredentialsBucketMismatch\";\n StorageValidationErrorCode[\"LocationCredentialsCrossBucket\"] = \"LocationCredentialsCrossBucket\";\n StorageValidationErrorCode[\"LocationCredentialsPathMismatch\"] = \"LocationCredentialsPathMismatch\";\n StorageValidationErrorCode[\"LocationCredentialsPermissionMismatch\"] = \"LocationCredentialsPermissionMismatch\";\n StorageValidationErrorCode[\"InvalidS3Uri\"] = \"InvalidS3Uri\";\n})(StorageValidationErrorCode = exports.StorageValidationErrorCode || (exports.StorageValidationErrorCode = {}));\n// Common error message strings to save some bytes\nconst LOCATION_SPECIFIC_CREDENTIALS = 'Location-specific credentials';\nconst DOES_NOT_MATCH = 'does not match that required for the API call';\nexports.validationErrorMap = {\n [StorageValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [StorageValidationErrorCode.NoIdentityId]: {\n message: 'Missing identity ID when accessing objects in protected or private access level.',\n },\n [StorageValidationErrorCode.NoKey]: {\n message: 'Missing key in api call.',\n },\n [StorageValidationErrorCode.NoSourceKey]: {\n message: 'Missing source key in copy api call.',\n },\n [StorageValidationErrorCode.NoDestinationKey]: {\n message: 'Missing destination key in copy api call.',\n },\n [StorageValidationErrorCode.NoSourcePath]: {\n message: 'Missing source path in copy api call.',\n },\n [StorageValidationErrorCode.NoDestinationPath]: {\n message: 'Missing destination path in copy api call.',\n },\n [StorageValidationErrorCode.NoBucket]: {\n message: 'Missing bucket name while accessing object.',\n },\n [StorageValidationErrorCode.NoRegion]: {\n message: 'Missing region while accessing object.',\n },\n [StorageValidationErrorCode.UrlExpirationMaxLimitExceed]: {\n message: 'Url Expiration can not be greater than 7 Days.',\n },\n [StorageValidationErrorCode.ObjectIsTooLarge]: {\n message: 'Object size cannot not be greater than 5TB.',\n },\n [StorageValidationErrorCode.InvalidUploadSource]: {\n message: 'Upload source type can only be a `Blob`, `File`, `ArrayBuffer`, or `string`.',\n },\n [StorageValidationErrorCode.InvalidStorageOperationInput]: {\n message: 'Path or key parameter must be specified in the input. Both can not be specified at the same time.',\n },\n [StorageValidationErrorCode.InvalidStorageOperationPrefixInput]: {\n message: 'Both path and prefix can not be specified at the same time.',\n },\n [StorageValidationErrorCode.InvalidStoragePathInput]: {\n message: 'Input `path` does not allow a leading slash (/).',\n },\n [StorageValidationErrorCode.InvalidLocationCredentialsCacheSize]: {\n message: 'locationCredentialsCacheSize must be a positive integer.',\n },\n [StorageValidationErrorCode.LocationCredentialsStoreDestroyed]: {\n message: `${LOCATION_SPECIFIC_CREDENTIALS} store has been destroyed.`,\n },\n [StorageValidationErrorCode.InvalidS3Uri]: {\n message: 'Invalid S3 URI.',\n },\n [StorageValidationErrorCode.LocationCredentialsCrossBucket]: {\n message: `${LOCATION_SPECIFIC_CREDENTIALS} cannot be used across buckets.`,\n },\n [StorageValidationErrorCode.LocationCredentialsBucketMismatch]: {\n message: `${LOCATION_SPECIFIC_CREDENTIALS} bucket ${DOES_NOT_MATCH}.`,\n },\n [StorageValidationErrorCode.LocationCredentialsPathMismatch]: {\n message: `${LOCATION_SPECIFIC_CREDENTIALS} path ${DOES_NOT_MATCH}.`,\n },\n [StorageValidationErrorCode.LocationCredentialsPermissionMismatch]: {\n message: `${LOCATION_SPECIFIC_CREDENTIALS} permission ${DOES_NOT_MATCH}.`,\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,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AAE,CAAC,EAAE,6BAA6B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAC3E,KAAK;AACL,IAAI,CAAC,0BAA0B,CAAC,qCAAqC,GAAG;AACxE,QAAQ,OAAO,EAAE,CAAC,EAAE,6BAA6B,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AACjF,KAAK;AACL,CAAC;;"}
|
|
@@ -8,6 +8,7 @@ const core_1 = require("@aws-amplify/core");
|
|
|
8
8
|
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
9
|
const resolveS3ConfigAndInput_1 = require("../utils/resolveS3ConfigAndInput");
|
|
10
10
|
const utils_2 = require("../utils");
|
|
11
|
+
const config_1 = require("../utils/config");
|
|
11
12
|
const client_1 = require("../utils/client");
|
|
12
13
|
const userAgent_1 = require("../utils/userAgent");
|
|
13
14
|
const utils_3 = require("../../../utils");
|
|
@@ -25,7 +26,11 @@ function downloadData(input) {
|
|
|
25
26
|
exports.downloadData = downloadData;
|
|
26
27
|
const downloadDataJob = (downloadDataInput, abortSignal) => async () => {
|
|
27
28
|
const { options: downloadDataOptions } = downloadDataInput;
|
|
28
|
-
const
|
|
29
|
+
const config = (0, config_1.createStorageConfiguration)(core_1.Amplify);
|
|
30
|
+
const { bucket, keyPrefix, s3Config, identityId } = await (0, resolveS3ConfigAndInput_1.resolveS3ConfigAndInput)({
|
|
31
|
+
config,
|
|
32
|
+
apiOptions: downloadDataOptions,
|
|
33
|
+
});
|
|
29
34
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(downloadDataInput, identityId);
|
|
30
35
|
const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
|
|
31
36
|
utils_3.logger.debug(`download ${objectKey} from ${finalKey}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadData.js","sources":["../../../../../src/providers/s3/apis/downloadData.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.downloadData = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst resolveS3ConfigAndInput_1 = require(\"../utils/resolveS3ConfigAndInput\");\nconst utils_2 = require(\"../utils\");\nconst client_1 = require(\"../utils/client\");\nconst userAgent_1 = require(\"../utils/userAgent\");\nconst utils_3 = require(\"../../../utils\");\nconst constants_1 = require(\"../utils/constants\");\nfunction downloadData(input) {\n const abortController = new AbortController();\n const downloadTask = (0, utils_2.createDownloadTask)({\n job: downloadDataJob(input, abortController.signal),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n return downloadTask;\n}\nexports.downloadData = downloadData;\nconst downloadDataJob = (downloadDataInput, abortSignal) => async () => {\n const { options: downloadDataOptions } = downloadDataInput;\n const { bucket, keyPrefix, s3Config, identityId } = await (0, resolveS3ConfigAndInput_1.resolveS3ConfigAndInput)(
|
|
1
|
+
{"version":3,"file":"downloadData.js","sources":["../../../../../src/providers/s3/apis/downloadData.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.downloadData = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst resolveS3ConfigAndInput_1 = require(\"../utils/resolveS3ConfigAndInput\");\nconst utils_2 = require(\"../utils\");\nconst config_1 = require(\"../utils/config\");\nconst client_1 = require(\"../utils/client\");\nconst userAgent_1 = require(\"../utils/userAgent\");\nconst utils_3 = require(\"../../../utils\");\nconst constants_1 = require(\"../utils/constants\");\nfunction downloadData(input) {\n const abortController = new AbortController();\n const downloadTask = (0, utils_2.createDownloadTask)({\n job: downloadDataJob(input, abortController.signal),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n return downloadTask;\n}\nexports.downloadData = downloadData;\nconst downloadDataJob = (downloadDataInput, abortSignal) => async () => {\n const { options: downloadDataOptions } = downloadDataInput;\n const config = (0, config_1.createStorageConfiguration)(core_1.Amplify);\n const { bucket, keyPrefix, s3Config, identityId } = await (0, resolveS3ConfigAndInput_1.resolveS3ConfigAndInput)({\n config,\n apiOptions: downloadDataOptions,\n });\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(downloadDataInput, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n utils_3.logger.debug(`download ${objectKey} from ${finalKey}.`);\n const { Body: body, LastModified: lastModified, ContentLength: size, ETag: eTag, Metadata: metadata, VersionId: versionId, ContentType: contentType, } = await (0, client_1.getObject)({\n ...s3Config,\n abortSignal,\n onDownloadProgress: downloadDataOptions?.onProgress,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.DownloadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n ...(downloadDataOptions?.bytesRange && {\n Range: `bytes=${downloadDataOptions.bytesRange.start}-${downloadDataOptions.bytesRange.end}`,\n }),\n });\n const result = {\n body,\n lastModified,\n size,\n contentType,\n eTag,\n metadata,\n versionId,\n };\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,yBAAyB,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9E,MAAM,OAAO,GAA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AI,OAAO,SAAS,KAAK,WAAW,CAAC,iBAAiB;AACtD,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;AACvC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;AACzC,CAAC;;"}
|
|
@@ -20,7 +20,10 @@ const copy = async (amplify, input) => {
|
|
|
20
20
|
exports.copy = copy;
|
|
21
21
|
const copyWithPath = async (amplify, input) => {
|
|
22
22
|
const { source, destination } = input;
|
|
23
|
-
const
|
|
23
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
24
|
+
const { s3Config, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
25
|
+
config,
|
|
26
|
+
});
|
|
24
27
|
(0, assertValidationError_1.assertValidationError)(!!source.path, validation_1.StorageValidationErrorCode.NoSourcePath);
|
|
25
28
|
(0, assertValidationError_1.assertValidationError)(!!destination.path, validation_1.StorageValidationErrorCode.NoDestinationPath);
|
|
26
29
|
const { objectKey: sourcePath } = (0, utils_2.validateStorageOperationInput)(source, identityId);
|
|
@@ -41,8 +44,15 @@ const copyWithKey = async (amplify, input) => {
|
|
|
41
44
|
const { source: { key: sourceKey }, destination: { key: destinationKey }, } = input;
|
|
42
45
|
(0, assertValidationError_1.assertValidationError)(!!sourceKey, validation_1.StorageValidationErrorCode.NoSourceKey);
|
|
43
46
|
(0, assertValidationError_1.assertValidationError)(!!destinationKey, validation_1.StorageValidationErrorCode.NoDestinationKey);
|
|
44
|
-
const
|
|
45
|
-
const { keyPrefix:
|
|
47
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
48
|
+
const { s3Config, bucket, keyPrefix: sourceKeyPrefix, } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
49
|
+
config,
|
|
50
|
+
apiOptions: input.source,
|
|
51
|
+
});
|
|
52
|
+
const { keyPrefix: destinationKeyPrefix } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
53
|
+
config,
|
|
54
|
+
apiOptions: input.destination,
|
|
55
|
+
}); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.
|
|
46
56
|
// TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is "protected", currently it's ${srcLevel}`
|
|
47
57
|
const finalCopySource = `${bucket}/${sourceKeyPrefix}${sourceKey}`;
|
|
48
58
|
const finalCopyDestination = `${destinationKeyPrefix}${destinationKey}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.js","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.copyWithKey = exports.copy = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst isCopyInputWithPath = (input) => (0, utils_2.isInputWithPath)(input.source);\nconst copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : (0, exports.copyWithKey)(amplify, input);\n};\nexports.copy = copy;\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n const { s3Config, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
1
|
+
{"version":3,"file":"copy.js","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.copyWithKey = exports.copy = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst isCopyInputWithPath = (input) => (0, utils_2.isInputWithPath)(input.source);\nconst copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : (0, exports.copyWithKey)(amplify, input);\n};\nexports.copy = copy;\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n });\n (0, assertValidationError_1.assertValidationError)(!!source.path, validation_1.StorageValidationErrorCode.NoSourcePath);\n (0, assertValidationError_1.assertValidationError)(!!destination.path, validation_1.StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = (0, utils_2.validateStorageOperationInput)(source, identityId);\n const { objectKey: destinationPath } = (0, utils_2.validateStorageOperationInput)(destination, identityId);\n const finalCopySource = `${bucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket,\n s3Config,\n });\n return { path: finalCopyDestination };\n};\n/** @deprecated Use {@link copyWithPath} instead. */\nconst copyWithKey = async (amplify, input) => {\n const { source: { key: sourceKey }, destination: { key: destinationKey }, } = input;\n (0, assertValidationError_1.assertValidationError)(!!sourceKey, validation_1.StorageValidationErrorCode.NoSourceKey);\n (0, assertValidationError_1.assertValidationError)(!!destinationKey, validation_1.StorageValidationErrorCode.NoDestinationKey);\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, bucket, keyPrefix: sourceKeyPrefix, } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: input.source,\n });\n const { keyPrefix: destinationKeyPrefix } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: input.destination,\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is \"protected\", currently it's ${srcLevel}`\n const finalCopySource = `${bucket}/${sourceKeyPrefix}${sourceKey}`;\n const finalCopyDestination = `${destinationKeyPrefix}${destinationKey}`;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket,\n s3Config,\n });\n return {\n key: destinationKey,\n };\n};\nexports.copyWithKey = copyWithKey;\nconst serviceCopy = async ({ source, destination, bucket, s3Config, }) => {\n await (0, client_1.copyObject)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: source,\n Key: destination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n });\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,YAAY,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACpE,MAAM,uBAAuB,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAC1F,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,OAAO,GAAG,OAAO,CAAC,mB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"}
|
|
@@ -12,7 +12,11 @@ const utils_3 = require("../../../../utils");
|
|
|
12
12
|
const constants_1 = require("../../utils/constants");
|
|
13
13
|
const getProperties = async (amplify, input, action) => {
|
|
14
14
|
const { options: getPropertiesOptions } = input;
|
|
15
|
-
const
|
|
15
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
16
|
+
const { s3Config, bucket, keyPrefix, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
17
|
+
config,
|
|
18
|
+
apiOptions: getPropertiesOptions,
|
|
19
|
+
});
|
|
16
20
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);
|
|
17
21
|
const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
|
|
18
22
|
utils_3.logger.debug(`get properties of ${objectKey} from ${finalKey}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProperties.js","sources":["../../../../../../src/providers/s3/apis/internal/getProperties.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getProperties = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst getProperties = async (amplify, input, action) => {\n const { options: getPropertiesOptions } = input;\n const { s3Config, bucket, keyPrefix, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
1
|
+
{"version":3,"file":"getProperties.js","sources":["../../../../../../src/providers/s3/apis/internal/getProperties.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getProperties = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst getProperties = async (amplify, input, action) => {\n const { options: getPropertiesOptions } = input;\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, bucket, keyPrefix, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: getPropertiesOptions,\n });\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n utils_3.logger.debug(`get properties of ${objectKey} from ${finalKey}`);\n const response = await (0, client_1.headObject)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(action ?? utils_1.StorageAction.GetProperties),\n }, {\n Bucket: bucket,\n Key: finalKey,\n });\n const result = {\n contentType: response.ContentType,\n size: response.ContentLength,\n eTag: response.ETag,\n lastModified: response.LastModified,\n metadata: response.Metadata,\n versionId: response.VersionId,\n };\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\nexports.getProperties = getProperties;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA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,QAAQ,CAAC,WAAW;AACzC,QAAQ,IAAI,EAAE,QAAQ,CAAC,aAAa;AACpC,QAAQ,IAAI,EAAE,QAAQ,CAAC,IAAI;AAC3B,QAAQ,YAAY,EAAE,QAAQ,CAAC,YAAY;AAC3C,QAAQ,QAAQ,EAAE,QAAQ,CAAC,QAAQ;AACnC,QAAQ,SAAS,EAAE,QAAQ,CAAC,SAAS;AACrC,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,KAAK,WAAW,CAAC,iBAAiB;AACtD,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;AACvC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;AACzC,CAAC,CAAC;AACF,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -13,7 +13,11 @@ const constants_1 = require("../../utils/constants");
|
|
|
13
13
|
const getProperties_1 = require("./getProperties");
|
|
14
14
|
const getUrl = async (amplify, input) => {
|
|
15
15
|
const { options: getUrlOptions } = input;
|
|
16
|
-
const
|
|
16
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
17
|
+
const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
18
|
+
config,
|
|
19
|
+
apiOptions: getUrlOptions,
|
|
20
|
+
});
|
|
17
21
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);
|
|
18
22
|
const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
|
|
19
23
|
if (getUrlOptions?.validateObjectExistence) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUrl.js","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst client_1 = require(\"../../utils/client\");\nconst utils_2 = require(\"../../utils\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst constants_1 = require(\"../../utils/constants\");\nconst getProperties_1 = require(\"./getProperties\");\nconst getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
1
|
+
{"version":3,"file":"getUrl.js","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst client_1 = require(\"../../utils/client\");\nconst utils_2 = require(\"../../utils\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst constants_1 = require(\"../../utils/constants\");\nconst getProperties_1 = require(\"./getProperties\");\nconst getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: getUrlOptions,\n });\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await (0, getProperties_1.getProperties)(amplify, input, utils_1.StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? constants_1.DEFAULT_PRESIGN_EXPIRATION;\n const resolvedCredential = typeof s3Config.credentials === 'function'\n ? await s3Config.credentials()\n : s3Config.credentials;\n const awsCredExpiration = resolvedCredential.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = constants_1.MAX_URL_EXPIRATION / 1000;\n (0, assertValidationError_1.assertValidationError)(urlExpirationInSec <= maxUrlExpirationInSec, validation_1.StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await (0, client_1.getPresignedGetObjectUrl)({\n ...s3Config,\n credentials: resolvedCredential,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\nexports.getUrl = getUrl;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,uBAAuB,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAC1F,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnD,MAAM,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AACzC,IAAI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;AAC7C,IAAI,MAAM,MAAM,GA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qB,GAAG,WAAW,CAAC,kBAAkB,GAAG,IAAI,CAAC;AACxE,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,YAAY,CAAC,0BAA0B,CAAC,2BAA2B,CAAC,CAAC;AACzK;AACA,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE;AAC1D,YAAY,GAAG,QAAQ;AACvB,YAAY,WAAW,EAAE,kBAAkB;AAC3C,YAAY,UAAU,EAAE,kBAAkB;AAC1C,SAAS,EAAE;AACX,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,EAAE,QAAQ;AACzB,SAAS,CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,MAAM;;"}
|
|
@@ -13,7 +13,11 @@ const constants_1 = require("../../utils/constants");
|
|
|
13
13
|
const MAX_PAGE_SIZE = 1000;
|
|
14
14
|
const list = async (amplify, input) => {
|
|
15
15
|
const { options = {} } = input;
|
|
16
|
-
const
|
|
16
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
17
|
+
const { s3Config, bucket, keyPrefix: generatedPrefix, identityId, } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
18
|
+
config,
|
|
19
|
+
apiOptions: options,
|
|
20
|
+
});
|
|
17
21
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInputWithPrefix)(input, identityId);
|
|
18
22
|
const isInputWithPrefix = inputType === constants_1.STORAGE_INPUT_PREFIX;
|
|
19
23
|
// @ts-expect-error pageSize and nextToken should not coexist with listAll
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../../../src/providers/s3/apis/internal/list.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.list = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst MAX_PAGE_SIZE = 1000;\nconst list = async (amplify, input) => {\n const { options = {} } = input;\n const { s3Config, bucket, keyPrefix: generatedPrefix, identityId, } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, options);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInputWithPrefix)(input, identityId);\n const isInputWithPrefix = inputType === constants_1.STORAGE_INPUT_PREFIX;\n // @ts-expect-error pageSize and nextToken should not coexist with listAll\n if (options?.listAll && (options?.pageSize || options?.nextToken)) {\n const anyOptions = options;\n utils_3.logger.debug(`listAll is set to true, ignoring ${anyOptions?.pageSize ? `pageSize: ${anyOptions?.pageSize}` : ''} ${anyOptions?.nextToken ? `nextToken: ${anyOptions?.nextToken}` : ''}.`);\n }\n const listParams = {\n Bucket: bucket,\n Prefix: isInputWithPrefix ? `${generatedPrefix}${objectKey}` : objectKey,\n MaxKeys: options?.listAll ? undefined : options?.pageSize,\n ContinuationToken: options?.listAll ? undefined : options?.nextToken,\n Delimiter: options?.delimiter,\n };\n utils_3.logger.debug(`listing items from \"${listParams.Prefix}\"`);\n const listInputArgs = {\n s3Config,\n listParams,\n };\n if (options.listAll) {\n if (isInputWithPrefix) {\n return _listAllWithPrefix({\n ...listInputArgs,\n generatedPrefix,\n });\n }\n else {\n return _listAllWithPath(listInputArgs);\n }\n }\n else {\n if (isInputWithPrefix) {\n return _listWithPrefix({ ...listInputArgs, generatedPrefix });\n }\n else {\n return _listWithPath(listInputArgs);\n }\n }\n};\nexports.list = list;\n/** @deprecated Use {@link _listAllWithPath} instead. */\nconst _listAllWithPrefix = async ({ s3Config, listParams, generatedPrefix, }) => {\n const listResult = [];\n let continuationToken = listParams.ContinuationToken;\n do {\n const { items: pageResults, nextToken: pageNextToken } = await _listWithPrefix({\n generatedPrefix,\n s3Config,\n listParams: {\n ...listParams,\n ContinuationToken: continuationToken,\n MaxKeys: MAX_PAGE_SIZE,\n },\n });\n listResult.push(...pageResults);\n continuationToken = pageNextToken;\n } while (continuationToken);\n return {\n items: listResult,\n };\n};\n/** @deprecated Use {@link _listWithPath} instead. */\nconst _listWithPrefix = async ({ s3Config, listParams, generatedPrefix, }) => {\n const listParamsClone = { ...listParams };\n if (!listParamsClone.MaxKeys || listParamsClone.MaxKeys > MAX_PAGE_SIZE) {\n utils_3.logger.debug(`defaulting pageSize to ${MAX_PAGE_SIZE}.`);\n listParamsClone.MaxKeys = MAX_PAGE_SIZE;\n }\n const response = await (0, client_1.listObjectsV2)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.List),\n }, listParamsClone);\n if (!response?.Contents) {\n return {\n items: [],\n };\n }\n return {\n items: response.Contents.map(item => ({\n key: generatedPrefix\n ? item.Key.substring(generatedPrefix.length)\n : item.Key,\n eTag: item.ETag,\n lastModified: item.LastModified,\n size: item.Size,\n })),\n nextToken: response.NextContinuationToken,\n };\n};\nconst _listAllWithPath = async ({ s3Config, listParams, }) => {\n const listResult = [];\n const subpaths = [];\n let continuationToken = listParams.ContinuationToken;\n do {\n const { items: pageResults, subpaths: pageSubpaths, nextToken: pageNextToken, } = await _listWithPath({\n s3Config,\n listParams: {\n ...listParams,\n ContinuationToken: continuationToken,\n MaxKeys: MAX_PAGE_SIZE,\n },\n });\n listResult.push(...pageResults);\n subpaths.push(...(pageSubpaths ?? []));\n continuationToken = pageNextToken;\n } while (continuationToken);\n return {\n items: listResult,\n ...parseSubpaths(subpaths),\n };\n};\nconst _listWithPath = async ({ s3Config, listParams, }) => {\n const listParamsClone = { ...listParams };\n if (!listParamsClone.MaxKeys || listParamsClone.MaxKeys > MAX_PAGE_SIZE) {\n utils_3.logger.debug(`defaulting pageSize to ${MAX_PAGE_SIZE}.`);\n listParamsClone.MaxKeys = MAX_PAGE_SIZE;\n }\n const { Contents: contents, NextContinuationToken: nextContinuationToken, CommonPrefixes: commonPrefixes, } = await (0, client_1.listObjectsV2)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.List),\n }, listParamsClone);\n const subpaths = mapCommonPrefixesToSubpaths(commonPrefixes);\n if (!contents) {\n return {\n items: [],\n ...parseSubpaths(subpaths),\n };\n }\n return {\n items: contents.map(item => ({\n path: item.Key,\n eTag: item.ETag,\n lastModified: item.LastModified,\n size: item.Size,\n })),\n nextToken: nextContinuationToken,\n ...parseSubpaths(subpaths),\n };\n};\nfunction mapCommonPrefixesToSubpaths(commonPrefixes) {\n const mappedSubpaths = commonPrefixes?.map(({ Prefix }) => Prefix);\n return mappedSubpaths?.filter((subpath) => !!subpath);\n}\nfunction parseSubpaths(subpaths) {\n return subpaths && subpaths.length > 0 ? { subpaths } : {};\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACtB,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,aAAa,GAA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AAC,CAAC;AACF,SAAS,2BAA2B,CAAC,cAAc,EAAE;AACrD,IAAI,MAAM,cAAc,GAAG,cAAc,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,CAAC;AACvE,IAAI,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AAC1D,CAAC;AACD,SAAS,aAAa,CAAC,QAAQ,EAAE;AACjC,IAAI,OAAO,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAC/D;;"}
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../../src/providers/s3/apis/internal/list.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.list = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst MAX_PAGE_SIZE = 1000;\nconst list = async (amplify, input) => {\n const { options = {} } = input;\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, bucket, keyPrefix: generatedPrefix, identityId, } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: options,\n });\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInputWithPrefix)(input, identityId);\n const isInputWithPrefix = inputType === constants_1.STORAGE_INPUT_PREFIX;\n // @ts-expect-error pageSize and nextToken should not coexist with listAll\n if (options?.listAll && (options?.pageSize || options?.nextToken)) {\n const anyOptions = options;\n utils_3.logger.debug(`listAll is set to true, ignoring ${anyOptions?.pageSize ? `pageSize: ${anyOptions?.pageSize}` : ''} ${anyOptions?.nextToken ? `nextToken: ${anyOptions?.nextToken}` : ''}.`);\n }\n const listParams = {\n Bucket: bucket,\n Prefix: isInputWithPrefix ? `${generatedPrefix}${objectKey}` : objectKey,\n MaxKeys: options?.listAll ? undefined : options?.pageSize,\n ContinuationToken: options?.listAll ? undefined : options?.nextToken,\n Delimiter: options?.delimiter,\n };\n utils_3.logger.debug(`listing items from \"${listParams.Prefix}\"`);\n const listInputArgs = {\n s3Config,\n listParams,\n };\n if (options.listAll) {\n if (isInputWithPrefix) {\n return _listAllWithPrefix({\n ...listInputArgs,\n generatedPrefix,\n });\n }\n else {\n return _listAllWithPath(listInputArgs);\n }\n }\n else {\n if (isInputWithPrefix) {\n return _listWithPrefix({ ...listInputArgs, generatedPrefix });\n }\n else {\n return _listWithPath(listInputArgs);\n }\n }\n};\nexports.list = list;\n/** @deprecated Use {@link _listAllWithPath} instead. */\nconst _listAllWithPrefix = async ({ s3Config, listParams, generatedPrefix, }) => {\n const listResult = [];\n let continuationToken = listParams.ContinuationToken;\n do {\n const { items: pageResults, nextToken: pageNextToken } = await _listWithPrefix({\n generatedPrefix,\n s3Config,\n listParams: {\n ...listParams,\n ContinuationToken: continuationToken,\n MaxKeys: MAX_PAGE_SIZE,\n },\n });\n listResult.push(...pageResults);\n continuationToken = pageNextToken;\n } while (continuationToken);\n return {\n items: listResult,\n };\n};\n/** @deprecated Use {@link _listWithPath} instead. */\nconst _listWithPrefix = async ({ s3Config, listParams, generatedPrefix, }) => {\n const listParamsClone = { ...listParams };\n if (!listParamsClone.MaxKeys || listParamsClone.MaxKeys > MAX_PAGE_SIZE) {\n utils_3.logger.debug(`defaulting pageSize to ${MAX_PAGE_SIZE}.`);\n listParamsClone.MaxKeys = MAX_PAGE_SIZE;\n }\n const response = await (0, client_1.listObjectsV2)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.List),\n }, listParamsClone);\n if (!response?.Contents) {\n return {\n items: [],\n };\n }\n return {\n items: response.Contents.map(item => ({\n key: generatedPrefix\n ? item.Key.substring(generatedPrefix.length)\n : item.Key,\n eTag: item.ETag,\n lastModified: item.LastModified,\n size: item.Size,\n })),\n nextToken: response.NextContinuationToken,\n };\n};\nconst _listAllWithPath = async ({ s3Config, listParams, }) => {\n const listResult = [];\n const subpaths = [];\n let continuationToken = listParams.ContinuationToken;\n do {\n const { items: pageResults, subpaths: pageSubpaths, nextToken: pageNextToken, } = await _listWithPath({\n s3Config,\n listParams: {\n ...listParams,\n ContinuationToken: continuationToken,\n MaxKeys: MAX_PAGE_SIZE,\n },\n });\n listResult.push(...pageResults);\n subpaths.push(...(pageSubpaths ?? []));\n continuationToken = pageNextToken;\n } while (continuationToken);\n return {\n items: listResult,\n ...parseSubpaths(subpaths),\n };\n};\nconst _listWithPath = async ({ s3Config, listParams, }) => {\n const listParamsClone = { ...listParams };\n if (!listParamsClone.MaxKeys || listParamsClone.MaxKeys > MAX_PAGE_SIZE) {\n utils_3.logger.debug(`defaulting pageSize to ${MAX_PAGE_SIZE}.`);\n listParamsClone.MaxKeys = MAX_PAGE_SIZE;\n }\n const { Contents: contents, NextContinuationToken: nextContinuationToken, CommonPrefixes: commonPrefixes, } = await (0, client_1.listObjectsV2)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.List),\n }, listParamsClone);\n const subpaths = mapCommonPrefixesToSubpaths(commonPrefixes);\n if (!contents) {\n return {\n items: [],\n ...parseSubpaths(subpaths),\n };\n }\n return {\n items: contents.map(item => ({\n path: item.Key,\n eTag: item.ETag,\n lastModified: item.LastModified,\n size: item.Size,\n })),\n nextToken: nextContinuationToken,\n ...parseSubpaths(subpaths),\n };\n};\nfunction mapCommonPrefixesToSubpaths(commonPrefixes) {\n const mappedSubpaths = commonPrefixes?.map(({ Prefix }) => Prefix);\n return mappedSubpaths?.filter((subpath) => !!subpath);\n}\nfunction parseSubpaths(subpaths) {\n return subpaths && subpaths.length > 0 ? { subpaths } :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,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7F,KAAK,EAAE,eAAe,CAAC,CAAC;AACxB,IAAI,MAAM,QAAQ,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC;AACjE,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO;AACf,YAAY,KAAK,EAAE,EAAE;AACrB,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC;AACtC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK;AACrC,YAAY,IAAI,EAAE,IAAI,CAAC,GAAG;AAC1B,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,YAAY,YAAY,EAAE,IAAI,CAAC,YAAY;AAC3C,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,SAAS,CAAC,CAAC;AACX,QAAQ,SAAS,EAAE,qBAAqB;AACxC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAClC,KAAK,CAAC;AACN,CAAC,CAAC;AACF,SAAS,2BAA2B,CAAC,cAAc,EAAE;AACrD,IAAI,MAAM,cAAc,GAAG,cAAc,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,CAAC;AACvE,IAAI,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AAC1D,CAAC;AACD,SAAS,aAAa,CAAC,QAAQ,EAAE;AACjC,IAAI,OAAO,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAC/D;;"}
|
|
@@ -12,7 +12,11 @@ const utils_3 = require("../../../../utils");
|
|
|
12
12
|
const constants_1 = require("../../utils/constants");
|
|
13
13
|
const remove = async (amplify, input) => {
|
|
14
14
|
const { options = {} } = input ?? {};
|
|
15
|
-
const
|
|
15
|
+
const config = (0, utils_2.createStorageConfiguration)(amplify);
|
|
16
|
+
const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
17
|
+
config,
|
|
18
|
+
apiOptions: options,
|
|
19
|
+
});
|
|
16
20
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);
|
|
17
21
|
let finalKey;
|
|
18
22
|
if (inputType === constants_1.STORAGE_INPUT_KEY) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","sources":["../../../../../../src/providers/s3/apis/internal/remove.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.remove = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst remove = async (amplify, input) => {\n const { options = {} } = input ?? {};\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
1
|
+
{"version":3,"file":"remove.js","sources":["../../../../../../src/providers/s3/apis/internal/remove.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.remove = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst constants_1 = require(\"../../utils/constants\");\nconst remove = async (amplify, input) => {\n const { options = {} } = input ?? {};\n const config = (0, utils_2.createStorageConfiguration)(amplify);\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)({\n config,\n apiOptions: options,\n });\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);\n let finalKey;\n if (inputType === constants_1.STORAGE_INPUT_KEY) {\n finalKey = `${keyPrefix}${objectKey}`;\n utils_3.logger.debug(`remove \"${objectKey}\" from \"${finalKey}\".`);\n }\n else {\n finalKey = objectKey;\n utils_3.logger.debug(`removing object in path \"${finalKey}\"`);\n }\n await (0, client_1.deleteObject)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.Remove),\n }, {\n Bucket: bucket,\n Key: finalKey,\n });\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? {\n key: objectKey,\n }\n : {\n path: objectKey,\n };\n};\nexports.remove = remove;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AACzC,IAAI,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;AACzC,IAAI,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,0BAA0B,EAAE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B,SAAS,CAAC;AACV,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../src/providers/s3/apis/internal/types/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.internalUploadData = void 0;
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const assertValidationError_1 = require("../../../../errors/utils/assertValidationError");
|
|
9
|
+
const validation_1 = require("../../../../errors/types/validation");
|
|
10
|
+
const constants_1 = require("../../utils/constants");
|
|
11
|
+
const byteLength_1 = require("../uploadData/byteLength");
|
|
12
|
+
const putObjectJob_1 = require("../uploadData/putObjectJob");
|
|
13
|
+
const multipart_1 = require("../uploadData/multipart");
|
|
14
|
+
function internalUploadData(config, input) {
|
|
15
|
+
const { data } = input;
|
|
16
|
+
const dataByteLength = (0, byteLength_1.byteLength)(data);
|
|
17
|
+
(0, assertValidationError_1.assertValidationError)(dataByteLength === undefined || dataByteLength <= constants_1.MAX_OBJECT_SIZE, validation_1.StorageValidationErrorCode.ObjectIsTooLarge);
|
|
18
|
+
if (dataByteLength && dataByteLength <= constants_1.DEFAULT_PART_SIZE) {
|
|
19
|
+
// Single part upload
|
|
20
|
+
const abortController = new AbortController();
|
|
21
|
+
return (0, utils_1.createUploadTask)({
|
|
22
|
+
isMultipartUpload: false,
|
|
23
|
+
job: (0, putObjectJob_1.putObjectJob)({
|
|
24
|
+
config,
|
|
25
|
+
input,
|
|
26
|
+
abortSignal: abortController.signal,
|
|
27
|
+
totalLength: dataByteLength,
|
|
28
|
+
}),
|
|
29
|
+
onCancel: (message) => {
|
|
30
|
+
abortController.abort(message);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Multipart upload
|
|
36
|
+
const { multipartUploadJob, onPause, onResume, onCancel } = (0, multipart_1.getMultipartUploadHandlers)({ config, input, size: dataByteLength });
|
|
37
|
+
return (0, utils_1.createUploadTask)({
|
|
38
|
+
isMultipartUpload: true,
|
|
39
|
+
job: multipartUploadJob,
|
|
40
|
+
onCancel: (message) => {
|
|
41
|
+
onCancel(message);
|
|
42
|
+
},
|
|
43
|
+
onPause,
|
|
44
|
+
onResume,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.internalUploadData = internalUploadData;
|
|
49
|
+
//# sourceMappingURL=uploadData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadData.js","sources":["../../../../../../src/providers/s3/apis/internal/uploadData.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.internalUploadData = void 0;\nconst utils_1 = require(\"../../utils\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst constants_1 = require(\"../../utils/constants\");\nconst byteLength_1 = require(\"../uploadData/byteLength\");\nconst putObjectJob_1 = require(\"../uploadData/putObjectJob\");\nconst multipart_1 = require(\"../uploadData/multipart\");\nfunction internalUploadData(config, input) {\n const { data } = input;\n const dataByteLength = (0, byteLength_1.byteLength)(data);\n (0, assertValidationError_1.assertValidationError)(dataByteLength === undefined || dataByteLength <= constants_1.MAX_OBJECT_SIZE, validation_1.StorageValidationErrorCode.ObjectIsTooLarge);\n if (dataByteLength && dataByteLength <= constants_1.DEFAULT_PART_SIZE) {\n // Single part upload\n const abortController = new AbortController();\n return (0, utils_1.createUploadTask)({\n isMultipartUpload: false,\n job: (0, putObjectJob_1.putObjectJob)({\n config,\n input,\n abortSignal: abortController.signal,\n totalLength: dataByteLength,\n }),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n }\n else {\n // Multipart upload\n const { multipartUploadJob, onPause, onResume, onCancel } = (0, multipart_1.getMultipartUploadHandlers)({ config, input, size: dataByteLength });\n return (0, utils_1.createUploadTask)({\n isMultipartUpload: true,\n job: multipartUploadJob,\n onCancel: (message) => {\n onCancel(message);\n },\n onPause,\n onResume,\n });\n }\n}\nexports.internalUploadData = internalUploadData;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,uBAAuB,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAC1F,MAAM,YAAY,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACpE,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,YAAY,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACzD,MAAM,cAAc,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACvD,SAAS,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE;AAC3C,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KA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ACnB,YAAY,QAAQ;AACpB,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -4,41 +4,12 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.uploadData = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const constants_1 = require("../../utils/constants");
|
|
11
|
-
const byteLength_1 = require("./byteLength");
|
|
12
|
-
const putObjectJob_1 = require("./putObjectJob");
|
|
13
|
-
const multipart_1 = require("./multipart");
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const uploadData_1 = require("../internal/uploadData");
|
|
9
|
+
const config_1 = require("../../utils/config");
|
|
14
10
|
function uploadData(input) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
(0, assertValidationError_1.assertValidationError)(dataByteLength === undefined || dataByteLength <= constants_1.MAX_OBJECT_SIZE, validation_1.StorageValidationErrorCode.ObjectIsTooLarge);
|
|
18
|
-
if (dataByteLength && dataByteLength <= constants_1.DEFAULT_PART_SIZE) {
|
|
19
|
-
// Single part upload
|
|
20
|
-
const abortController = new AbortController();
|
|
21
|
-
return (0, utils_1.createUploadTask)({
|
|
22
|
-
isMultipartUpload: false,
|
|
23
|
-
job: (0, putObjectJob_1.putObjectJob)(input, abortController.signal, dataByteLength),
|
|
24
|
-
onCancel: (message) => {
|
|
25
|
-
abortController.abort(message);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// Multipart upload
|
|
31
|
-
const { multipartUploadJob, onPause, onResume, onCancel } = (0, multipart_1.getMultipartUploadHandlers)(input, dataByteLength);
|
|
32
|
-
return (0, utils_1.createUploadTask)({
|
|
33
|
-
isMultipartUpload: true,
|
|
34
|
-
job: multipartUploadJob,
|
|
35
|
-
onCancel: (message) => {
|
|
36
|
-
onCancel(message);
|
|
37
|
-
},
|
|
38
|
-
onPause,
|
|
39
|
-
onResume,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
11
|
+
const config = (0, config_1.createStorageConfiguration)(core_1.Amplify);
|
|
12
|
+
return (0, uploadData_1.internalUploadData)(config, input);
|
|
42
13
|
}
|
|
43
14
|
exports.uploadData = uploadData;
|
|
44
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/providers/s3/apis/uploadData/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = void 0;\nconst
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/providers/s3/apis/uploadData/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst uploadData_1 = require(\"../internal/uploadData\");\nconst config_1 = require(\"../../utils/config\");\nfunction uploadData(input) {\n const config = (0, config_1.createStorageConfiguration)(core_1.Amplify);\n return (0, uploadData_1.internalUploadData)(config, input);\n}\nexports.uploadData = uploadData;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,IAAI,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5E,IAAI,OAAO,IAAI,YAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
|
@@ -18,13 +18,7 @@ const uploadCache_1 = require("./uploadCache");
|
|
|
18
18
|
const progressTracker_1 = require("./progressTracker");
|
|
19
19
|
const initialUpload_1 = require("./initialUpload");
|
|
20
20
|
const getDataChunker_1 = require("./getDataChunker");
|
|
21
|
-
|
|
22
|
-
* Create closure hiding the multipart upload implementation details and expose the upload job and control functions(
|
|
23
|
-
* onPause, onResume, onCancel).
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
21
|
+
const getMultipartUploadHandlers = ({ config, input, size, }) => {
|
|
28
22
|
let resolveCallback;
|
|
29
23
|
let rejectCallback;
|
|
30
24
|
let inProgressUpload;
|
|
@@ -41,14 +35,17 @@ const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
|
41
35
|
// This should be replaced by a special abort reason. However,the support of this API is lagged behind.
|
|
42
36
|
let isAbortSignalFromPause = false;
|
|
43
37
|
const startUpload = async () => {
|
|
44
|
-
const { options: uploadDataOptions, data } =
|
|
45
|
-
const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
38
|
+
const { options: uploadDataOptions, data } = input;
|
|
39
|
+
const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)({
|
|
40
|
+
config,
|
|
41
|
+
apiOptions: uploadDataOptions,
|
|
42
|
+
});
|
|
46
43
|
abortController = new AbortController();
|
|
47
44
|
isAbortSignalFromPause = false;
|
|
48
45
|
resolvedS3Config = resolvedS3Options.s3Config;
|
|
49
46
|
resolvedBucket = resolvedS3Options.bucket;
|
|
50
47
|
resolvedIdentityId = resolvedS3Options.identityId;
|
|
51
|
-
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(
|
|
48
|
+
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, resolvedIdentityId);
|
|
52
49
|
const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};
|
|
53
50
|
finalKey = objectKey;
|
|
54
51
|
// Resolve "key" specific options
|