@aws-amplify/storage 6.0.20 → 6.0.21-gen2-storage.7da2b89.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.
Files changed (132) hide show
  1. package/dist/cjs/errors/types/validation.js +18 -2
  2. package/dist/cjs/errors/types/validation.js.map +1 -1
  3. package/dist/cjs/providers/s3/apis/copy.js +1 -13
  4. package/dist/cjs/providers/s3/apis/copy.js.map +1 -1
  5. package/dist/cjs/providers/s3/apis/downloadData.js +11 -36
  6. package/dist/cjs/providers/s3/apis/downloadData.js.map +1 -1
  7. package/dist/cjs/providers/s3/apis/getProperties.js +1 -12
  8. package/dist/cjs/providers/s3/apis/getProperties.js.map +1 -1
  9. package/dist/cjs/providers/s3/apis/getUrl.js +1 -19
  10. package/dist/cjs/providers/s3/apis/getUrl.js.map +1 -1
  11. package/dist/cjs/providers/s3/apis/internal/copy.js +41 -7
  12. package/dist/cjs/providers/s3/apis/internal/copy.js.map +1 -1
  13. package/dist/cjs/providers/s3/apis/internal/getProperties.js +10 -6
  14. package/dist/cjs/providers/s3/apis/internal/getProperties.js.map +1 -1
  15. package/dist/cjs/providers/s3/apis/internal/getUrl.js +13 -6
  16. package/dist/cjs/providers/s3/apis/internal/getUrl.js.map +1 -1
  17. package/dist/cjs/providers/s3/apis/internal/remove.js +20 -7
  18. package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
  19. package/dist/cjs/providers/s3/apis/remove.js +1 -10
  20. package/dist/cjs/providers/s3/apis/remove.js.map +1 -1
  21. package/dist/cjs/providers/s3/apis/server/copy.js +3 -5
  22. package/dist/cjs/providers/s3/apis/server/copy.js.map +1 -1
  23. package/dist/cjs/providers/s3/apis/server/getProperties.js +1 -3
  24. package/dist/cjs/providers/s3/apis/server/getProperties.js.map +1 -1
  25. package/dist/cjs/providers/s3/apis/server/getUrl.js +1 -3
  26. package/dist/cjs/providers/s3/apis/server/getUrl.js.map +1 -1
  27. package/dist/cjs/providers/s3/apis/server/remove.js +1 -3
  28. package/dist/cjs/providers/s3/apis/server/remove.js.map +1 -1
  29. package/dist/cjs/providers/s3/utils/constants.js +3 -1
  30. package/dist/cjs/providers/s3/utils/constants.js.map +1 -1
  31. package/dist/cjs/providers/s3/utils/index.js +5 -1
  32. package/dist/cjs/providers/s3/utils/index.js.map +1 -1
  33. package/dist/cjs/providers/s3/utils/isInputWithPath.js +11 -0
  34. package/dist/cjs/providers/s3/utils/isInputWithPath.js.map +1 -0
  35. package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js +2 -1
  36. package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js.map +1 -1
  37. package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js +31 -0
  38. package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js.map +1 -0
  39. package/dist/esm/errors/types/validation.d.ts +6 -2
  40. package/dist/esm/errors/types/validation.mjs +18 -2
  41. package/dist/esm/errors/types/validation.mjs.map +1 -1
  42. package/dist/esm/providers/s3/apis/copy.d.ts +29 -12
  43. package/dist/esm/providers/s3/apis/copy.mjs +1 -13
  44. package/dist/esm/providers/s3/apis/copy.mjs.map +1 -1
  45. package/dist/esm/providers/s3/apis/downloadData.d.ts +70 -32
  46. package/dist/esm/providers/s3/apis/downloadData.mjs +12 -36
  47. package/dist/esm/providers/s3/apis/downloadData.mjs.map +1 -1
  48. package/dist/esm/providers/s3/apis/getProperties.d.ts +28 -11
  49. package/dist/esm/providers/s3/apis/getProperties.mjs +1 -12
  50. package/dist/esm/providers/s3/apis/getProperties.mjs.map +1 -1
  51. package/dist/esm/providers/s3/apis/getUrl.d.ts +42 -18
  52. package/dist/esm/providers/s3/apis/getUrl.mjs +1 -19
  53. package/dist/esm/providers/s3/apis/getUrl.mjs.map +1 -1
  54. package/dist/esm/providers/s3/apis/internal/copy.d.ts +3 -1
  55. package/dist/esm/providers/s3/apis/internal/copy.mjs +41 -6
  56. package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
  57. package/dist/esm/providers/s3/apis/internal/getProperties.mjs +11 -6
  58. package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
  59. package/dist/esm/providers/s3/apis/internal/getUrl.mjs +15 -7
  60. package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
  61. package/dist/esm/providers/s3/apis/internal/remove.mjs +21 -7
  62. package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
  63. package/dist/esm/providers/s3/apis/remove.d.ts +26 -9
  64. package/dist/esm/providers/s3/apis/remove.mjs +1 -10
  65. package/dist/esm/providers/s3/apis/remove.mjs.map +1 -1
  66. package/dist/esm/providers/s3/apis/server/copy.d.ts +31 -2
  67. package/dist/esm/providers/s3/apis/server/copy.mjs +1 -3
  68. package/dist/esm/providers/s3/apis/server/copy.mjs.map +1 -1
  69. package/dist/esm/providers/s3/apis/server/getProperties.d.ts +30 -2
  70. package/dist/esm/providers/s3/apis/server/getProperties.mjs +1 -3
  71. package/dist/esm/providers/s3/apis/server/getProperties.mjs.map +1 -1
  72. package/dist/esm/providers/s3/apis/server/getUrl.d.ts +44 -2
  73. package/dist/esm/providers/s3/apis/server/getUrl.mjs +1 -3
  74. package/dist/esm/providers/s3/apis/server/getUrl.mjs.map +1 -1
  75. package/dist/esm/providers/s3/apis/server/remove.d.ts +28 -2
  76. package/dist/esm/providers/s3/apis/server/remove.mjs +1 -3
  77. package/dist/esm/providers/s3/apis/server/remove.mjs.map +1 -1
  78. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.d.ts +1 -1
  79. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.d.ts +1 -1
  80. package/dist/esm/providers/s3/types/index.d.ts +3 -3
  81. package/dist/esm/providers/s3/types/inputs.d.ts +29 -7
  82. package/dist/esm/providers/s3/types/options.d.ts +23 -5
  83. package/dist/esm/providers/s3/types/outputs.d.ts +33 -10
  84. package/dist/esm/providers/s3/utils/constants.d.ts +2 -0
  85. package/dist/esm/providers/s3/utils/constants.mjs +3 -1
  86. package/dist/esm/providers/s3/utils/constants.mjs.map +1 -1
  87. package/dist/esm/providers/s3/utils/index.d.ts +2 -0
  88. package/dist/esm/providers/s3/utils/index.mjs +2 -0
  89. package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
  90. package/dist/esm/providers/s3/utils/isInputWithPath.d.ts +2 -0
  91. package/dist/esm/providers/s3/utils/isInputWithPath.mjs +8 -0
  92. package/dist/esm/providers/s3/utils/isInputWithPath.mjs.map +1 -0
  93. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.d.ts +2 -1
  94. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs +2 -1
  95. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs.map +1 -1
  96. package/dist/esm/providers/s3/utils/validateStorageOperationInput.d.ts +5 -0
  97. package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs +29 -0
  98. package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs.map +1 -0
  99. package/dist/esm/types/index.d.ts +2 -2
  100. package/dist/esm/types/inputs.d.ts +42 -8
  101. package/dist/esm/types/options.d.ts +1 -0
  102. package/dist/esm/types/outputs.d.ts +22 -6
  103. package/package.json +107 -107
  104. package/src/errors/types/validation.ts +19 -2
  105. package/src/providers/s3/apis/copy.ts +38 -15
  106. package/src/providers/s3/apis/downloadData.ts +105 -47
  107. package/src/providers/s3/apis/getProperties.ts +38 -15
  108. package/src/providers/s3/apis/getUrl.ts +48 -22
  109. package/src/providers/s3/apis/internal/copy.ts +90 -8
  110. package/src/providers/s3/apis/internal/getProperties.ts +19 -9
  111. package/src/providers/s3/apis/internal/getUrl.ts +29 -11
  112. package/src/providers/s3/apis/internal/remove.ts +28 -10
  113. package/src/providers/s3/apis/remove.ts +35 -12
  114. package/src/providers/s3/apis/server/copy.ts +49 -6
  115. package/src/providers/s3/apis/server/getProperties.ts +48 -6
  116. package/src/providers/s3/apis/server/getUrl.ts +56 -5
  117. package/src/providers/s3/apis/server/remove.ts +46 -5
  118. package/src/providers/s3/apis/uploadData/multipart/uploadHandlers.ts +1 -1
  119. package/src/providers/s3/apis/uploadData/putObjectJob.ts +1 -1
  120. package/src/providers/s3/types/index.ts +26 -5
  121. package/src/providers/s3/types/inputs.ts +64 -18
  122. package/src/providers/s3/types/options.ts +44 -21
  123. package/src/providers/s3/types/outputs.ts +47 -10
  124. package/src/providers/s3/utils/constants.ts +3 -0
  125. package/src/providers/s3/utils/index.ts +2 -0
  126. package/src/providers/s3/utils/isInputWithPath.ts +13 -0
  127. package/src/providers/s3/utils/resolveS3ConfigAndInput.ts +3 -2
  128. package/src/providers/s3/utils/validateStorageOperationInput.ts +39 -0
  129. package/src/types/index.ts +12 -5
  130. package/src/types/inputs.ts +61 -11
  131. package/src/types/options.ts +1 -0
  132. package/src/types/outputs.ts +25 -6
@@ -1 +1 @@
1
- {"version":3,"file":"downloadData.mjs","sources":["../../../../../src/providers/s3/apis/downloadData.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput } from '../utils/resolveS3ConfigAndInput';\nimport { createDownloadTask } from '../utils';\nimport { getObject } from '../utils/client';\nimport { getStorageUserAgentValue } from '../utils/userAgent';\nimport { logger } from '../../../utils';\n/**\n * Download S3 object data to memory\n *\n * @param input - The DownloadDataInput object.\n * @returns A cancelable task exposing result promise from `result` property.\n * @throws service: {@link S3Exception} - thrown when checking for existence of the object\n * @throws validation: {@link StorageValidationErrorCode } - Validation errors\n *\n * @example\n * ```ts\n * // Download a file from s3 bucket\n * const { body, eTag } = await downloadData({ key, data: file, options: {\n * onProgress, // Optional progress callback.\n * } }).result;\n * ```\n * @example\n * ```ts\n * // Cancel a task\n * const downloadTask = downloadData({ key, data: file });\n * //...\n * downloadTask.cancel();\n * try {\n * \tawait downloadTask.result;\n * } catch (error) {\n * \tif(isCancelError(error)) {\n * // Handle error thrown by task cancelation.\n * \t}\n * }\n *```\n */\nexport const downloadData = (input) => {\n const abortController = new AbortController();\n const downloadTask = createDownloadTask({\n job: downloadDataJob(input, abortController.signal),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n return downloadTask;\n};\nconst downloadDataJob = ({ options: downloadDataOptions, key }, abortSignal) => async () => {\n const { bucket, keyPrefix, s3Config } = await resolveS3ConfigAndInput(Amplify, downloadDataOptions);\n const finalKey = keyPrefix + key;\n logger.debug(`download ${key} from ${finalKey}.`);\n const { Body: body, LastModified: lastModified, ContentLength: size, ETag: eTag, Metadata: metadata, VersionId: versionId, ContentType: contentType, } = await getObject({\n ...s3Config,\n abortSignal,\n onDownloadProgress: downloadDataOptions?.onProgress,\n userAgentValue: getStorageUserAgentValue(StorageAction.DownloadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n ...(downloadDataOptions?.bytesRange && {\n Range: `bytes=${downloadDataOptions.bytesRange.start}-${downloadDataOptions.bytesRange.end}`,\n }),\n });\n return {\n key,\n body,\n lastModified,\n size,\n contentType,\n eTag,\n metadata,\n versionId,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,CAAC,KAAK,KAAK;AACvC,IAAI,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAClD,IAAI,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAC5C,QAAQ,GAAG,EAAE,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC;AAC3D,QAAQ,QAAQ,EAAE,CAAC,OAAO,KAAK;AAC/B,YAAY,eAAe,CAAC,KAAK,CAAC,OAAO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AACpB,QAAQ,IAAI;AACZ,QAAQ,WAAW;AACnB,QAAQ,IAAI;AACZ,QAAQ,QAAQ;AAChB,QAAQ,SAAS;AACjB,KAAK,CAAC;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"downloadData.mjs","sources":["../../../../../src/providers/s3/apis/downloadData.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput } from '../utils/resolveS3ConfigAndInput';\nimport { createDownloadTask, validateStorageOperationInput } from '../utils';\nimport { getObject } from '../utils/client';\nimport { getStorageUserAgentValue } from '../utils/userAgent';\nimport { logger } from '../../../utils';\nimport { STORAGE_INPUT_KEY } from '../utils/constants';\nexport const downloadData = (input) => {\n const abortController = new AbortController();\n const downloadTask = createDownloadTask({\n job: downloadDataJob(input, abortController.signal),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n return downloadTask;\n};\nconst downloadDataJob = (downloadDataInput, abortSignal) => async () => {\n const { options: downloadDataOptions } = downloadDataInput;\n const { bucket, keyPrefix, s3Config, identityId } = await resolveS3ConfigAndInput(Amplify, downloadDataOptions);\n const { inputType, objectKey } = validateStorageOperationInput(downloadDataInput, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n logger.debug(`download ${objectKey} from ${finalKey}.`);\n const { Body: body, LastModified: lastModified, ContentLength: size, ETag: eTag, Metadata: metadata, VersionId: versionId, ContentType: contentType, } = await getObject({\n ...s3Config,\n abortSignal,\n onDownloadProgress: downloadDataOptions?.onProgress,\n userAgentValue: getStorageUserAgentValue(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 === STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: finalKey, ...result };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AASY,MAAC,YAAY,GAAG,CAAC,KAAK,KAAK;AACvC,IAAI,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAClD,IAAI,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAC5C,QAAQ,GAAG,EAAE,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC;AAC3D,QAAQ,QAAQ,EAAE,CAAC,OAAO,KAAK;AAC/B,YAAY,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3C,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,YAAY,CAAC;AACxB,EAAE;AACF,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,WAAW,KAAK,YAAY;AACxE,IAAI,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,iBAAiB,CAAC;AAC/D,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AACpH,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAClG,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACzF,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,GAAG,MAAM,SAAS,CAAC;AAC7K,QAAQ,GAAG,QAAQ;AACnB,QAAQ,WAAW;AACnB,QAAQ,kBAAkB,EAAE,mBAAmB,EAAE,UAAU;AAC3D,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,YAAY,CAAC;AAC5E,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,QAAQ,IAAI,mBAAmB,EAAE,UAAU,IAAI;AAC/C,YAAY,KAAK,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACxG,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,IAAI;AACZ,QAAQ,YAAY;AACpB,QAAQ,IAAI;AACZ,QAAQ,WAAW;AACnB,QAAQ,IAAI;AACZ,QAAQ,QAAQ;AAChB,QAAQ,SAAS;AACjB,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,KAAK,iBAAiB;AAC1C,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;AACvC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;AACxC,CAAC;;;;"}
@@ -1,11 +1,28 @@
1
- import { GetPropertiesInput, GetPropertiesOutput } from '../types';
2
- /**
3
- * Gets the properties of a file. The properties include S3 system metadata and
4
- * the user metadata that was provided when uploading the file.
5
- *
6
- * @param input - The GetPropertiesInput object.
7
- * @returns Requested object properties.
8
- * @throws A {@link S3Exception} when the underlying S3 service returned error.
9
- * @throws A {@link StorageValidationErrorCode} when API call parameters are invalid.
10
- */
11
- export declare const getProperties: (input: GetPropertiesInput) => Promise<GetPropertiesOutput>;
1
+ import { GetPropertiesInputKey, GetPropertiesInputPath, GetPropertiesOutputKey, GetPropertiesOutputPath } from '../types';
2
+ interface GetProperties {
3
+ /**
4
+ * Gets the properties of a file. The properties include S3 system metadata and
5
+ * the user metadata that was provided when uploading the file.
6
+ *
7
+ * @param input - The `GetPropertiesInputPath` object.
8
+ * @returns Requested object properties.
9
+ * @throws An `S3Exception` when the underlying S3 service returned error.
10
+ * @throws A `StorageValidationErrorCode` when API call parameters are invalid.
11
+ */
12
+ (input: GetPropertiesInputPath): Promise<GetPropertiesOutputPath>;
13
+ /**
14
+ * @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
15
+ * Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/get-properties/ | path} instead.
16
+ *
17
+ * Gets the properties of a file. The properties include S3 system metadata and
18
+ * the user metadata that was provided when uploading the file.
19
+ *
20
+ * @param input - The `GetPropertiesInputKey` object.
21
+ * @returns Requested object properties.
22
+ * @throws An `S3Exception` when the underlying S3 service returned error.
23
+ * @throws A `StorageValidationErrorCode` when API call parameters are invalid.
24
+ */
25
+ (input: GetPropertiesInputKey): Promise<GetPropertiesOutputKey>;
26
+ }
27
+ export declare const getProperties: GetProperties;
28
+ export {};
@@ -3,18 +3,7 @@ import { getProperties as getProperties$1 } from './internal/getProperties.mjs';
3
3
 
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
- /**
7
- * Gets the properties of a file. The properties include S3 system metadata and
8
- * the user metadata that was provided when uploading the file.
9
- *
10
- * @param input - The GetPropertiesInput object.
11
- * @returns Requested object properties.
12
- * @throws A {@link S3Exception} when the underlying S3 service returned error.
13
- * @throws A {@link StorageValidationErrorCode} when API call parameters are invalid.
14
- */
15
- const getProperties = (input) => {
16
- return getProperties$1(Amplify, input);
17
- };
6
+ const getProperties = (input) => getProperties$1(Amplify, input);
18
7
 
19
8
  export { getProperties };
20
9
  //# sourceMappingURL=getProperties.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getProperties.mjs","sources":["../../../../../src/providers/s3/apis/getProperties.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { getProperties as getPropertiesInternal } from './internal/getProperties';\n/**\n * Gets the properties of a file. The properties include S3 system metadata and\n * the user metadata that was provided when uploading the file.\n *\n * @param input - The GetPropertiesInput object.\n * @returns Requested object properties.\n * @throws A {@link S3Exception} when the underlying S3 service returned error.\n * @throws A {@link StorageValidationErrorCode} when API call parameters are invalid.\n */\nexport const getProperties = (input) => {\n return getPropertiesInternal(Amplify, input);\n};\n"],"names":["getPropertiesInternal"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,KAAK,KAAK;AACxC,IAAI,OAAOA,eAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"getProperties.mjs","sources":["../../../../../src/providers/s3/apis/getProperties.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { getProperties as getPropertiesInternal } from './internal/getProperties';\nexport const getProperties = (input) => getPropertiesInternal(Amplify, input);\n"],"names":["getPropertiesInternal"],"mappings":";;;AAAA;AACA;AAGY,MAAC,aAAa,GAAG,CAAC,KAAK,KAAKA,eAAqB,CAAC,OAAO,EAAE,KAAK;;;;"}
@@ -1,18 +1,42 @@
1
- import { GetUrlInput, GetUrlOutput } from '../types';
2
- /**
3
- * Get a temporary presigned URL to download the specified S3 object.
4
- * The presigned URL expires when the associated role used to sign the request expires or
5
- * the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
6
- *
7
- * By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
8
- * to true, this method will verify the given object already exists in S3 before returning a presigned
9
- * URL, and will throw {@link StorageError} if the object does not exist.
10
- *
11
- * @param input - The GetUrlInput object.
12
- * @returns Presigned URL and timestamp when the URL MAY expire.
13
- * @throws service: {@link S3Exception} - thrown when checking for existence of the object
14
- * @throws validation: {@link StorageValidationErrorCode } - Validation errors
15
- * thrown either username or key are not defined.
16
- *
17
- */
18
- export declare const getUrl: (input: GetUrlInput) => Promise<GetUrlOutput>;
1
+ import { GetUrlInputKey, GetUrlInputPath, GetUrlOutput } from '../types';
2
+ interface GetUrl {
3
+ /**
4
+ * Get a temporary presigned URL to download the specified S3 object.
5
+ * The presigned URL expires when the associated role used to sign the request expires or
6
+ * the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
7
+ *
8
+ * By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
9
+ * to true, this method will verify the given object already exists in S3 before returning a presigned
10
+ * URL, and will throw `StorageError` if the object does not exist.
11
+ *
12
+ * @param input - The `GetUrlInputPath` object.
13
+ * @returns Presigned URL and timestamp when the URL MAY expire.
14
+ * @throws service: `S3Exception` - thrown when checking for existence of the object
15
+ * @throws validation: `StorageValidationErrorCode` - Validation errors
16
+ * thrown either username or key are not defined.
17
+ *
18
+ */
19
+ (input: GetUrlInputPath): Promise<GetUrlOutput>;
20
+ /**
21
+ * @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
22
+ * Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/download/#generate-a-download-url | path} instead.
23
+ *
24
+ * Get a temporary presigned URL to download the specified S3 object.
25
+ * The presigned URL expires when the associated role used to sign the request expires or
26
+ * the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
27
+ *
28
+ * By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
29
+ * to true, this method will verify the given object already exists in S3 before returning a presigned
30
+ * URL, and will throw `StorageError` if the object does not exist.
31
+ *
32
+ * @param input - The `GetUrlInputKey` object.
33
+ * @returns Presigned URL and timestamp when the URL MAY expire.
34
+ * @throws service: `S3Exception` - thrown when checking for existence of the object
35
+ * @throws validation: `StorageValidationErrorCode` - Validation errors
36
+ * thrown either username or key are not defined.
37
+ *
38
+ */
39
+ (input: GetUrlInputKey): Promise<GetUrlOutput>;
40
+ }
41
+ export declare const getUrl: GetUrl;
42
+ export {};
@@ -3,25 +3,7 @@ import { getUrl as getUrl$1 } from './internal/getUrl.mjs';
3
3
 
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
- /**
7
- * Get a temporary presigned URL to download the specified S3 object.
8
- * The presigned URL expires when the associated role used to sign the request expires or
9
- * the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.
10
- *
11
- * By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`
12
- * to true, this method will verify the given object already exists in S3 before returning a presigned
13
- * URL, and will throw {@link StorageError} if the object does not exist.
14
- *
15
- * @param input - The GetUrlInput object.
16
- * @returns Presigned URL and timestamp when the URL MAY expire.
17
- * @throws service: {@link S3Exception} - thrown when checking for existence of the object
18
- * @throws validation: {@link StorageValidationErrorCode } - Validation errors
19
- * thrown either username or key are not defined.
20
- *
21
- */
22
- const getUrl = (input) => {
23
- return getUrl$1(Amplify, input);
24
- };
6
+ const getUrl = (input) => getUrl$1(Amplify, input);
25
7
 
26
8
  export { getUrl };
27
9
  //# sourceMappingURL=getUrl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getUrl.mjs","sources":["../../../../../src/providers/s3/apis/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { getUrl as getUrlInternal } from './internal/getUrl';\n/**\n * Get a temporary presigned URL to download the specified S3 object.\n * The presigned URL expires when the associated role used to sign the request expires or\n * the option `expiresIn` is reached. The `expiresAt` property in the output object indicates when the URL MAY expire.\n *\n * By default, it will not validate the object that exists in S3. If you set the `options.validateObjectExistence`\n * to true, this method will verify the given object already exists in S3 before returning a presigned\n * URL, and will throw {@link StorageError} if the object does not exist.\n *\n * @param input - The GetUrlInput object.\n * @returns Presigned URL and timestamp when the URL MAY expire.\n * @throws service: {@link S3Exception} - thrown when checking for existence of the object\n * @throws validation: {@link StorageValidationErrorCode } - Validation errors\n * thrown either username or key are not defined.\n *\n */\nexport const getUrl = (input) => {\n return getUrlInternal(Amplify, input);\n};\n"],"names":["getUrlInternal"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,KAAK,KAAK;AACjC,IAAI,OAAOA,QAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C;;;;"}
1
+ {"version":3,"file":"getUrl.mjs","sources":["../../../../../src/providers/s3/apis/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { getUrl as getUrlInternal } from './internal/getUrl';\nexport const getUrl = (input) => getUrlInternal(Amplify, input);\n"],"names":["getUrlInternal"],"mappings":";;;AAAA;AACA;AAGY,MAAC,MAAM,GAAG,CAAC,KAAK,KAAKA,QAAc,CAAC,OAAO,EAAE,KAAK;;;;"}
@@ -1,3 +1,5 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
- import { CopyInput, CopyOutput } from '../../types';
2
+ import { CopyInput, CopyInputKey, CopyOutput, CopyOutputKey } from '../../types';
3
3
  export declare const copy: (amplify: AmplifyClassV6, input: CopyInput) => Promise<CopyOutput>;
4
+ /** @deprecated Use {@link copyWithPath} instead. */
5
+ export declare const copyWithKey: (amplify: AmplifyClassV6, input: CopyInputKey) => Promise<CopyOutputKey>;
@@ -9,6 +9,8 @@ import { resolveS3ConfigAndInput } from '../../utils/resolveS3ConfigAndInput.mjs
9
9
  import { assertValidationError } from '../../../../errors/utils/assertValidationError.mjs';
10
10
  import { StorageValidationErrorCode } from '../../../../errors/types/validation.mjs';
11
11
  import { logger } from '../../../../utils/logger.mjs';
12
+ import { validateStorageOperationInput } from '../../utils/validateStorageOperationInput.mjs';
13
+ import { isInputWithPath } from '../../utils/isInputWithPath.mjs';
12
14
  import '../../utils/client/base.mjs';
13
15
  import '../../utils/client/getObject.mjs';
14
16
  import '../../utils/client/listObjectsV2.mjs';
@@ -25,7 +27,32 @@ import { getStorageUserAgentValue } from '../../utils/userAgent.mjs';
25
27
 
26
28
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
29
  // SPDX-License-Identifier: Apache-2.0
30
+ const isCopyInputWithPath = (input) => isInputWithPath(input.source);
28
31
  const copy = async (amplify, input) => {
32
+ return isCopyInputWithPath(input)
33
+ ? copyWithPath(amplify, input)
34
+ : copyWithKey(amplify, input);
35
+ };
36
+ const copyWithPath = async (amplify, input) => {
37
+ const { source, destination } = input;
38
+ const { s3Config, bucket, identityId } = await resolveS3ConfigAndInput(amplify);
39
+ assertValidationError(!!source.path, StorageValidationErrorCode.NoSourcePath);
40
+ assertValidationError(!!destination.path, StorageValidationErrorCode.NoDestinationPath);
41
+ const { objectKey: sourcePath } = validateStorageOperationInput(source, identityId);
42
+ const { objectKey: destinationPath } = validateStorageOperationInput(destination, identityId);
43
+ const finalCopySource = `${bucket}/${sourcePath}`;
44
+ const finalCopyDestination = destinationPath;
45
+ logger.debug(`copying "${finalCopySource}" to "${finalCopyDestination}".`);
46
+ await serviceCopy({
47
+ source: finalCopySource,
48
+ destination: finalCopyDestination,
49
+ bucket,
50
+ s3Config,
51
+ });
52
+ return { path: finalCopyDestination };
53
+ };
54
+ /** @deprecated Use {@link copyWithPath} instead. */
55
+ const copyWithKey = async (amplify, input) => {
29
56
  const { source: { key: sourceKey }, destination: { key: destinationKey }, } = input;
30
57
  assertValidationError(!!sourceKey, StorageValidationErrorCode.NoSourceKey);
31
58
  assertValidationError(!!destinationKey, StorageValidationErrorCode.NoDestinationKey);
@@ -35,19 +62,27 @@ const copy = async (amplify, input) => {
35
62
  const finalCopySource = `${bucket}/${sourceKeyPrefix}${sourceKey}`;
36
63
  const finalCopyDestination = `${destinationKeyPrefix}${destinationKey}`;
37
64
  logger.debug(`copying "${finalCopySource}" to "${finalCopyDestination}".`);
65
+ await serviceCopy({
66
+ source: finalCopySource,
67
+ destination: finalCopyDestination,
68
+ bucket,
69
+ s3Config,
70
+ });
71
+ return {
72
+ key: destinationKey,
73
+ };
74
+ };
75
+ const serviceCopy = async ({ source, destination, bucket, s3Config, }) => {
38
76
  await copyObject({
39
77
  ...s3Config,
40
78
  userAgentValue: getStorageUserAgentValue(StorageAction.Copy),
41
79
  }, {
42
80
  Bucket: bucket,
43
- CopySource: finalCopySource,
44
- Key: finalCopyDestination,
81
+ CopySource: source,
82
+ Key: destination,
45
83
  MetadataDirective: 'COPY', // Copies over metadata like contentType as well
46
84
  });
47
- return {
48
- key: destinationKey,
49
- };
50
85
  };
51
86
 
52
- export { copy };
87
+ export { copy, copyWithKey };
53
88
  //# sourceMappingURL=copy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy.mjs","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput } from '../../utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { copyObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nexport const copy = async (amplify, input) => {\n const { source: { key: sourceKey }, destination: { key: destinationKey }, } = input;\n assertValidationError(!!sourceKey, StorageValidationErrorCode.NoSourceKey);\n assertValidationError(!!destinationKey, StorageValidationErrorCode.NoDestinationKey);\n const { s3Config, bucket, keyPrefix: sourceKeyPrefix, } = await resolveS3ConfigAndInput(amplify, input.source);\n const { keyPrefix: destinationKeyPrefix } = await resolveS3ConfigAndInput(amplify, input.destination); // 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 logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await copyObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: finalCopySource,\n Key: finalCopyDestination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n });\n return {\n key: destinationKey,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQY,MAAC,IAAI,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC9C,IAAI,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,KAAK,CAAC;AACxF,IAAI,qBAAqB,CAAC,CAAC,CAAC,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,CAAC;AAC/E,IAAI,qBAAqB,CAAC,CAAC,CAAC,cAAc,EAAE,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;AACzF,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;AACnH,IAAI,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AAC1G;AACA,IAAI,MAAM,eAAe,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AACvE,IAAI,MAAM,oBAAoB,GAAG,CAAC,EAAE,oBAAoB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AAC5E,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/E,IAAI,MAAM,UAAU,CAAC;AACrB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,IAAI,CAAC;AACpE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,eAAe;AACnC,QAAQ,GAAG,EAAE,oBAAoB;AACjC,QAAQ,iBAAiB,EAAE,MAAM;AACjC,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,cAAc;AAC3B,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"copy.mjs","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { isInputWithPath, resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { copyObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nconst isCopyInputWithPath = (input) => isInputWithPath(input.source);\nexport const copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : copyWithKey(amplify, input);\n};\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n const { s3Config, bucket, identityId } = await resolveS3ConfigAndInput(amplify);\n assertValidationError(!!source.path, StorageValidationErrorCode.NoSourcePath);\n assertValidationError(!!destination.path, StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = validateStorageOperationInput(source, identityId);\n const { objectKey: destinationPath } = validateStorageOperationInput(destination, identityId);\n const finalCopySource = `${bucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n 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. */\nexport const copyWithKey = async (amplify, input) => {\n const { source: { key: sourceKey }, destination: { key: destinationKey }, } = input;\n assertValidationError(!!sourceKey, StorageValidationErrorCode.NoSourceKey);\n assertValidationError(!!destinationKey, StorageValidationErrorCode.NoDestinationKey);\n const { s3Config, bucket, keyPrefix: sourceKeyPrefix, } = await resolveS3ConfigAndInput(amplify, input.source);\n const { keyPrefix: destinationKeyPrefix } = await resolveS3ConfigAndInput(amplify, input.destination); // 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 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};\nconst serviceCopy = async ({ source, destination, bucket, s3Config, }) => {\n await copyObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,mBAAmB,GAAG,CAAC,KAAK,KAAK,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACzD,MAAC,IAAI,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC9C,IAAI,OAAO,mBAAmB,CAAC,KAAK,CAAC;AACrC,UAAU,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;AACtC,UAAU,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACtC,EAAE;AACF,MAAM,YAAY,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC/C,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;AAC1C,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACpF,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAClF,IAAI,qBAAqB,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;AAC5F,IAAI,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,6BAA6B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACxF,IAAI,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,6BAA6B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAClG,IAAI,MAAM,eAAe,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;AACtD,IAAI,MAAM,oBAAoB,GAAG,eAAe,CAAC;AACjD,IAAI,MAAM,CAAC,KAAK,C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AAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/E,IAAI,MAAM,WAAW,CAAC;AACtB,QAAQ,MAAM,EAAE,eAAe;AAC/B,QAAQ,WAAW,EAAE,oBAAoB;AACzC,QAAQ,MAAM;AACd,QAAQ,QAAQ;AAChB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,cAAc;AAC3B,KAAK,CAAC;AACN,EAAE;AACF,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAG,KAAK;AAC1E,IAAI,MAAM,UAAU,CAAC;AACrB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,IAAI,CAAC;AACpE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,MAAM;AAC1B,QAAQ,GAAG,EAAE,WAAW;AACxB,QAAQ,iBAAiB,EAAE,MAAM;AACjC,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
@@ -8,6 +8,7 @@ import 'buffer';
8
8
  import { resolveS3ConfigAndInput } from '../../utils/resolveS3ConfigAndInput.mjs';
9
9
  import '../../../../errors/types/validation.mjs';
10
10
  import { logger } from '../../../../utils/logger.mjs';
11
+ import { validateStorageOperationInput } from '../../utils/validateStorageOperationInput.mjs';
11
12
  import '../../utils/client/base.mjs';
12
13
  import '../../utils/client/getObject.mjs';
13
14
  import '../../utils/client/listObjectsV2.mjs';
@@ -21,14 +22,16 @@ import '../../utils/client/copyObject.mjs';
21
22
  import { headObject } from '../../utils/client/headObject.mjs';
22
23
  import '../../utils/client/deleteObject.mjs';
23
24
  import { getStorageUserAgentValue } from '../../utils/userAgent.mjs';
25
+ import { STORAGE_INPUT_KEY } from '../../utils/constants.mjs';
24
26
 
25
27
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
26
28
  // SPDX-License-Identifier: Apache-2.0
27
29
  const getProperties = async (amplify, input, action) => {
28
- const { key, options } = input;
29
- const { s3Config, bucket, keyPrefix } = await resolveS3ConfigAndInput(amplify, options);
30
- const finalKey = `${keyPrefix}${key}`;
31
- logger.debug(`get properties of ${key} from ${finalKey}`);
30
+ const { options: getPropertiesOptions } = input;
31
+ const { s3Config, bucket, keyPrefix, identityId } = await resolveS3ConfigAndInput(amplify, getPropertiesOptions);
32
+ const { inputType, objectKey } = validateStorageOperationInput(input, identityId);
33
+ const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
34
+ logger.debug(`get properties of ${objectKey} from ${finalKey}`);
32
35
  const response = await headObject({
33
36
  ...s3Config,
34
37
  userAgentValue: getStorageUserAgentValue(action ?? StorageAction.GetProperties),
@@ -36,8 +39,7 @@ const getProperties = async (amplify, input, action) => {
36
39
  Bucket: bucket,
37
40
  Key: finalKey,
38
41
  });
39
- return {
40
- key,
42
+ const result = {
41
43
  contentType: response.ContentType,
42
44
  size: response.ContentLength,
43
45
  eTag: response.ETag,
@@ -45,6 +47,9 @@ const getProperties = async (amplify, input, action) => {
45
47
  metadata: response.Metadata,
46
48
  versionId: response.VersionId,
47
49
  };
50
+ return inputType === STORAGE_INPUT_KEY
51
+ ? { key: objectKey, ...result }
52
+ : { path: objectKey, ...result };
48
53
  };
49
54
 
50
55
  export { getProperties };
@@ -1 +1 @@
1
- {"version":3,"file":"getProperties.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getProperties.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput } from '../../utils';\nimport { headObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nexport const getProperties = async (amplify, input, action) => {\n const { key, options } = input;\n const { s3Config, bucket, keyPrefix } = await resolveS3ConfigAndInput(amplify, options);\n const finalKey = `${keyPrefix}${key}`;\n logger.debug(`get properties of ${key} from ${finalKey}`);\n const response = await headObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(action ?? StorageAction.GetProperties),\n }, {\n Bucket: bucket,\n Key: finalKey,\n });\n return {\n key,\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};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAMY,MAAC,aAAa,GAAG,OAAO,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK;AAC/D,IAAI,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AACnC,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5F,IAAI,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1C,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC9D,IAAI,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC;AACtC,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,MAAM,IAAI,aAAa,CAAC,aAAa,CAAC;AACvF,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG;AACX,QAAQ,WAAW,EAAE,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;;;;"}
1
+ {"version":3,"file":"getProperties.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getProperties.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { headObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nimport { STORAGE_INPUT_KEY } from '../../utils/constants';\nexport const getProperties = async (amplify, input, action) => {\n const { options: getPropertiesOptions } = input;\n const { s3Config, bucket, keyPrefix, identityId } = await resolveS3ConfigAndInput(amplify, getPropertiesOptions);\n const { inputType, objectKey } = validateStorageOperationInput(input, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n logger.debug(`get properties of ${objectKey} from ${finalKey}`);\n const response = await headObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(action ?? 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 === STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOY,MAAC,aAAa,GAAG,OAAO,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK;AAC/D,IAAI,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;AACpD,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE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  import { assertValidationError } from '../../../../errors/utils/assertValidationError.mjs';
23
23
  import '../../../../utils/logger.mjs';
24
- import { DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION } from '../../utils/constants.mjs';
24
+ import { validateStorageOperationInput } from '../../utils/validateStorageOperationInput.mjs';
25
+ import { STORAGE_INPUT_KEY, DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION } from '../../utils/constants.mjs';
25
26
  import { getProperties } from './getProperties.mjs';
26
27
 
27
28
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
28
29
  // SPDX-License-Identifier: Apache-2.0
29
30
  const getUrl = async (amplify, input) => {
30
- const { key, options } = input;
31
- if (options?.validateObjectExistence) {
32
- await getProperties(amplify, { key, options }, StorageAction.GetUrl);
31
+ const { options: getUrlOptions } = input;
32
+ const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, getUrlOptions);
33
+ const { inputType, objectKey } = validateStorageOperationInput(input, identityId);
34
+ const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
35
+ if (getUrlOptions?.validateObjectExistence) {
36
+ await getProperties(amplify, {
37
+ options: getUrlOptions,
38
+ ...(inputType === STORAGE_INPUT_KEY
39
+ ? { key: input.key }
40
+ : { path: input.path }),
41
+ }, StorageAction.GetUrl);
33
42
  }
34
- const { s3Config, keyPrefix, bucket } = await resolveS3ConfigAndInput(amplify, options);
35
- let urlExpirationInSec = options?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;
43
+ let urlExpirationInSec = getUrlOptions?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;
36
44
  const awsCredExpiration = s3Config.credentials?.expiration;
37
45
  if (awsCredExpiration) {
38
46
  const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);
@@ -47,7 +55,7 @@ const getUrl = async (amplify, input) => {
47
55
  expiration: urlExpirationInSec,
48
56
  }, {
49
57
  Bucket: bucket,
50
- Key: `${keyPrefix}${key}`,
58
+ Key: finalKey,
51
59
  }),
52
60
  expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),
53
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getUrl.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { getPresignedGetObjectUrl } from '../../utils/client';\nimport { resolveS3ConfigAndInput } from '../../utils';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION, } from '../../utils/constants';\nimport { getProperties } from './getProperties';\nexport const getUrl = async (amplify, input) => {\n const { key, options } = input;\n if (options?.validateObjectExistence) {\n await getProperties(amplify, { key, options }, StorageAction.GetUrl);\n }\n const { s3Config, keyPrefix, bucket } = await resolveS3ConfigAndInput(amplify, options);\n let urlExpirationInSec = options?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;\n const awsCredExpiration = s3Config.credentials?.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = MAX_URL_EXPIRATION / 1000;\n assertValidationError(urlExpirationInSec <= maxUrlExpirationInSec, StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await getPresignedGetObjectUrl({\n ...s3Config,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: `${keyPrefix}${key}`,\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQY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CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"getUrl.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { getPresignedGetObjectUrl } from '../../utils/client';\nimport { resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION, STORAGE_INPUT_KEY, } from '../../utils/constants';\nimport { getProperties } from './getProperties';\nexport const getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, getUrlOptions);\n const { inputType, objectKey } = validateStorageOperationInput(input, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await getProperties(amplify, {\n options: getUrlOptions,\n ...(inputType === STORAGE_INPUT_KEY\n ? { key: input.key }\n : { path: input.path }),\n }, StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;\n const awsCredExpiration = s3Config.credentials?.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = MAX_URL_EXPIRATION / 1000;\n assertValidationError(urlExpirationInSec <= maxUrlExpirationInSec, StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await getPresignedGetObjectUrl({\n ...s3Config,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQY,MAAC,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAChD,IAAI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;AAC7C,IAAI,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAC9G,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACtF,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACzF,IAAI,IAAI,aAAa,EAAE,uBAAuB,EAAE;AAChD,QAAQ,MAAM,aAAa,CAAC,OAAO,EAAE;AACrC,YAAY,OAAO,EAAE,aAAa;AAClC,YAAY,IAAI,SAAS,KAAK,iBAAiB;AAC/C,kBAAkB,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AACpC,kBAAkB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;AACtC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;AACjC,KAAK;AACL,IAAI,IAAI,kBAAkB,GAAG,aAAa,EAAE,SAAS,IAAI,0BAA0B,CAAC;AACpF,IAAI,MAAM,iBAAiB,GAAG,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;AAC/D,IAAI,IAAI,iBAAiB,EAAE;AAC3B,QAAQ,MAAM,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;AACrG,QAAQ,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;AAClF,KAAK;AACL,IAAI,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAC5D,IAAI,qBAAqB,CAAC,kBAAkB,IAAI,qBAAqB,EAAE,0BAA0B,CAAC,2BAA2B,CAAC,CAAC;AAC/H;AACA,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC5C,YAAY,GAAG,QAAQ;AACvB,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;;;;"}
@@ -8,6 +8,7 @@ import 'buffer';
8
8
  import { resolveS3ConfigAndInput } from '../../utils/resolveS3ConfigAndInput.mjs';
9
9
  import '../../../../errors/types/validation.mjs';
10
10
  import { logger } from '../../../../utils/logger.mjs';
11
+ import { validateStorageOperationInput } from '../../utils/validateStorageOperationInput.mjs';
11
12
  import '../../utils/client/base.mjs';
12
13
  import '../../utils/client/getObject.mjs';
13
14
  import '../../utils/client/listObjectsV2.mjs';
@@ -21,14 +22,23 @@ import '../../utils/client/copyObject.mjs';
21
22
  import '../../utils/client/headObject.mjs';
22
23
  import { deleteObject } from '../../utils/client/deleteObject.mjs';
23
24
  import { getStorageUserAgentValue } from '../../utils/userAgent.mjs';
25
+ import { STORAGE_INPUT_KEY } from '../../utils/constants.mjs';
24
26
 
25
27
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
26
28
  // SPDX-License-Identifier: Apache-2.0
27
29
  const remove = async (amplify, input) => {
28
- const { key, options = {} } = input;
29
- const { s3Config, keyPrefix, bucket } = await resolveS3ConfigAndInput(amplify, options);
30
- const finalKey = `${keyPrefix}${key}`;
31
- logger.debug(`remove "${key}" from "${finalKey}".`);
30
+ const { options = {} } = input ?? {};
31
+ const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, options);
32
+ const { inputType, objectKey } = validateStorageOperationInput(input, identityId);
33
+ let finalKey;
34
+ if (inputType === STORAGE_INPUT_KEY) {
35
+ finalKey = `${keyPrefix}${objectKey}`;
36
+ logger.debug(`remove "${objectKey}" from "${finalKey}".`);
37
+ }
38
+ else {
39
+ finalKey = objectKey;
40
+ logger.debug(`removing object in path "${finalKey}"`);
41
+ }
32
42
  await deleteObject({
33
43
  ...s3Config,
34
44
  userAgentValue: getStorageUserAgentValue(StorageAction.Remove),
@@ -36,9 +46,13 @@ const remove = async (amplify, input) => {
36
46
  Bucket: bucket,
37
47
  Key: finalKey,
38
48
  });
39
- return {
40
- key,
41
- };
49
+ return inputType === STORAGE_INPUT_KEY
50
+ ? {
51
+ key: objectKey,
52
+ }
53
+ : {
54
+ path: objectKey,
55
+ };
42
56
  };
43
57
 
44
58
  export { remove };
@@ -1 +1 @@
1
- {"version":3,"file":"remove.mjs","sources":["../../../../../../src/providers/s3/apis/internal/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput } from '../../utils';\nimport { deleteObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nexport const remove = async (amplify, input) => {\n const { key, options = {} } = input;\n const { s3Config, keyPrefix, bucket } = await resolveS3ConfigAndInput(amplify, options);\n const finalKey = `${keyPrefix}${key}`;\n logger.debug(`remove \"${key}\" from \"${finalKey}\".`);\n await deleteObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Remove),\n }, {\n Bucket: bucket,\n Key: finalKey,\n });\n return {\n key,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAMY,MAAC,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAChD,IAAI,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;AACxC,IAAI,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5F,IAAI,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1C,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,IAAI,MAAM,YAAY,CAAC;AACvB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,MAAM,CAAC;AACtE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG;AACX,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"remove.mjs","sources":["../../../../../../src/providers/s3/apis/internal/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { deleteObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nimport { STORAGE_INPUT_KEY } from '../../utils/constants';\nexport const remove = async (amplify, input) => {\n const { options = {} } = input ?? {};\n const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, options);\n const { inputType, objectKey } = validateStorageOperationInput(input, identityId);\n let finalKey;\n if (inputType === STORAGE_INPUT_KEY) {\n finalKey = `${keyPrefix}${objectKey}`;\n logger.debug(`remove \"${objectKey}\" from \"${finalKey}\".`);\n }\n else {\n finalKey = objectKey;\n logger.debug(`removing object in path \"${finalKey}\"`);\n }\n await deleteObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Remove),\n }, {\n Bucket: bucket,\n Key: finalKey,\n });\n return inputType === STORAGE_INPUT_KEY\n ? {\n key: objectKey,\n }\n : {\n path: objectKey,\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOY,MAAC,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAChD,IAAI,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;AACzC,IAAI,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACxG,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACtF,IAAI,IAAI,QAAQ,CAAC;AACjB,IAAI,IAAI,SAAS,KAAK,iBAAiB,EAAE;AACzC,QAAQ,QAAQ,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9C,QAAQ,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAClE,KAAK;AACL,SAAS;AACT,QAAQ,QAAQ,GAAG,SAAS,CAAC;AAC7B,QAAQ,MAAM,CAAC,KAAK,CAAC,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,KAAK;AACL,IAAI,MAAM,YAAY,CAAC;AACvB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,MAAM,CAAC;AACtE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,KAAK,iBAAiB;AAC1C,UAAU;AACV,YAAY,GAAG,EAAE,SAAS;AAC1B,SAAS;AACT,UAAU;AACV,YAAY,IAAI,EAAE,SAAS;AAC3B,SAAS,CAAC;AACV;;;;"}
@@ -1,9 +1,26 @@
1
- import { RemoveInput, RemoveOutput } from '../types';
2
- /**
3
- * Remove a file from your S3 bucket.
4
- * @param input - The RemoveInput object.
5
- * @return Output containing the removed object key
6
- * @throws service: {@link S3Exception} - S3 service errors thrown while getting properties
7
- * @throws validation: {@link StorageValidationErrorCode } - Validation errors thrown
8
- */
9
- export declare const remove: (input: RemoveInput) => Promise<RemoveOutput>;
1
+ import { RemoveInputKey, RemoveInputPath, RemoveOutputKey, RemoveOutputPath } from '../types';
2
+ interface RemoveApi {
3
+ /**
4
+ * Remove a file from your S3 bucket.
5
+ * @param input - The `RemoveInputPath` object.
6
+ * @return Output containing the removed object path.
7
+ * @throws service: `S3Exception` - S3 service errors thrown while while removing the object.
8
+ * @throws validation: `StorageValidationErrorCode` - Validation errors thrown
9
+ * when there is no path or path is empty or path has a leading slash.
10
+ */
11
+ (input: RemoveInputPath): Promise<RemoveOutputPath>;
12
+ /**
13
+ * @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
14
+ * Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/remove | path} instead.
15
+ *
16
+ * Remove a file from your S3 bucket.
17
+ * @param input - The `RemoveInputKey` object.
18
+ * @return Output containing the removed object key
19
+ * @throws service: `S3Exception` - S3 service errors thrown while while removing the object
20
+ * @throws validation: `StorageValidationErrorCode` - Validation errors thrown
21
+ * when there is no key or its empty.
22
+ */
23
+ (input: RemoveInputKey): Promise<RemoveOutputKey>;
24
+ }
25
+ export declare const remove: RemoveApi;
26
+ export {};
@@ -3,16 +3,7 @@ import { remove as remove$1 } from './internal/remove.mjs';
3
3
 
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
- /**
7
- * Remove a file from your S3 bucket.
8
- * @param input - The RemoveInput object.
9
- * @return Output containing the removed object key
10
- * @throws service: {@link S3Exception} - S3 service errors thrown while getting properties
11
- * @throws validation: {@link StorageValidationErrorCode } - Validation errors thrown
12
- */
13
- const remove = (input) => {
14
- return remove$1(Amplify, input);
15
- };
6
+ const remove = (input) => remove$1(Amplify, input);
16
7
 
17
8
  export { remove };
18
9
  //# sourceMappingURL=remove.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"remove.mjs","sources":["../../../../../src/providers/s3/apis/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { remove as removeInternal } from './internal/remove';\n/**\n * Remove a file from your S3 bucket.\n * @param input - The RemoveInput object.\n * @return Output containing the removed object key\n * @throws service: {@link S3Exception} - S3 service errors thrown while getting properties\n * @throws validation: {@link StorageValidationErrorCode } - Validation errors thrown\n */\nexport const remove = (input) => {\n return removeInternal(Amplify, input);\n};\n"],"names":["removeInternal"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,KAAK,KAAK;AACjC,IAAI,OAAOA,QAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C;;;;"}
1
+ {"version":3,"file":"remove.mjs","sources":["../../../../../src/providers/s3/apis/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { remove as removeInternal } from './internal/remove';\nexport const remove = (input) => removeInternal(Amplify, input);\n"],"names":["removeInternal"],"mappings":";;;AAAA;AACA;AAGY,MAAC,MAAM,GAAG,CAAC,KAAK,KAAKA,QAAc,CAAC,OAAO,EAAE,KAAK;;;;"}
@@ -1,3 +1,32 @@
1
1
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
2
- import { CopyInput, CopyOutput } from '../../types';
3
- export declare const copy: (contextSpec: AmplifyServer.ContextSpec, input: CopyInput) => Promise<CopyOutput>;
2
+ import { CopyInputKey, CopyInputPath, CopyOutputKey, CopyOutputPath } from '../../types';
3
+ interface Copy {
4
+ /**
5
+ * Copy an object from a source to a destination object within the same bucket.
6
+ *
7
+ * @param contextSpec - The isolated server context.
8
+ * @param input - The CopyInputPath object.
9
+ * @returns Output containing the destination object path.
10
+ * @throws service: `S3Exception` - Thrown when checking for existence of the object
11
+ * @throws validation: `StorageValidationErrorCode` - Thrown when
12
+ * source or destination path is not defined.
13
+ */
14
+ (contextSpec: AmplifyServer.ContextSpec, input: CopyInputPath): Promise<CopyOutputPath>;
15
+ /**
16
+ * @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
17
+ * Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/copy | path} instead.
18
+ *
19
+ * Copy an object from a source to a destination object within the same bucket. Can optionally copy files across
20
+ * different accessLevel or identityId (if source object's accessLevel is 'protected').
21
+ *
22
+ * @param contextSpec - The isolated server context.
23
+ * @param input - The CopyInputKey object.
24
+ * @returns Output containing the destination object key.
25
+ * @throws service: `S3Exception` - Thrown when checking for existence of the object
26
+ * @throws validation: `StorageValidationErrorCode` - Thrown when
27
+ * source or destination key is not defined.
28
+ */
29
+ (contextSpec: AmplifyServer.ContextSpec, input: CopyInputKey): Promise<CopyOutputKey>;
30
+ }
31
+ export declare const copy: Copy;
32
+ export {};