@aws-amplify/storage 6.0.28 → 6.0.29-gen2-storage.e54bfa9.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 (194) hide show
  1. package/dist/cjs/errors/types/validation.js +22 -2
  2. package/dist/cjs/errors/types/validation.js.map +1 -1
  3. package/dist/cjs/providers/s3/apis/copy.js +2 -12
  4. package/dist/cjs/providers/s3/apis/copy.js.map +1 -1
  5. package/dist/cjs/providers/s3/apis/downloadData.js +13 -38
  6. package/dist/cjs/providers/s3/apis/downloadData.js.map +1 -1
  7. package/dist/cjs/providers/s3/apis/getProperties.js +2 -11
  8. package/dist/cjs/providers/s3/apis/getProperties.js.map +1 -1
  9. package/dist/cjs/providers/s3/apis/getUrl.js +2 -18
  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 +8 -6
  16. package/dist/cjs/providers/s3/apis/internal/getUrl.js.map +1 -1
  17. package/dist/cjs/providers/s3/apis/internal/list.js +86 -16
  18. package/dist/cjs/providers/s3/apis/internal/list.js.map +1 -1
  19. package/dist/cjs/providers/s3/apis/internal/remove.js +20 -7
  20. package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
  21. package/dist/cjs/providers/s3/apis/list.js +4 -4
  22. package/dist/cjs/providers/s3/apis/list.js.map +1 -1
  23. package/dist/cjs/providers/s3/apis/remove.js +2 -9
  24. package/dist/cjs/providers/s3/apis/remove.js.map +1 -1
  25. package/dist/cjs/providers/s3/apis/server/copy.js +4 -4
  26. package/dist/cjs/providers/s3/apis/server/copy.js.map +1 -1
  27. package/dist/cjs/providers/s3/apis/server/getProperties.js +2 -2
  28. package/dist/cjs/providers/s3/apis/server/getProperties.js.map +1 -1
  29. package/dist/cjs/providers/s3/apis/server/getUrl.js +2 -2
  30. package/dist/cjs/providers/s3/apis/server/getUrl.js.map +1 -1
  31. package/dist/cjs/providers/s3/apis/server/list.js +4 -4
  32. package/dist/cjs/providers/s3/apis/server/list.js.map +1 -1
  33. package/dist/cjs/providers/s3/apis/server/remove.js +2 -2
  34. package/dist/cjs/providers/s3/apis/server/remove.js.map +1 -1
  35. package/dist/cjs/providers/s3/apis/uploadData/index.js +4 -50
  36. package/dist/cjs/providers/s3/apis/uploadData/index.js.map +1 -1
  37. package/dist/cjs/providers/s3/apis/uploadData/multipart/initialUpload.js +1 -1
  38. package/dist/cjs/providers/s3/apis/uploadData/multipart/initialUpload.js.map +1 -1
  39. package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadCache.js +8 -1
  40. package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadCache.js.map +1 -1
  41. package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadHandlers.js +28 -13
  42. package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadHandlers.js.map +1 -1
  43. package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js +10 -5
  44. package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js.map +1 -1
  45. package/dist/cjs/providers/s3/utils/client/utils/parsePayload.js +1 -1
  46. package/dist/cjs/providers/s3/utils/client/utils/parsePayload.js.map +1 -1
  47. package/dist/cjs/providers/s3/utils/constants.js +4 -1
  48. package/dist/cjs/providers/s3/utils/constants.js.map +1 -1
  49. package/dist/cjs/providers/s3/utils/index.js +7 -1
  50. package/dist/cjs/providers/s3/utils/index.js.map +1 -1
  51. package/dist/cjs/providers/s3/utils/isInputWithPath.js +11 -0
  52. package/dist/cjs/providers/s3/utils/isInputWithPath.js.map +1 -0
  53. package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js +2 -1
  54. package/dist/cjs/providers/s3/utils/resolveS3ConfigAndInput.js.map +1 -1
  55. package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js +31 -0
  56. package/dist/cjs/providers/s3/utils/validateStorageOperationInput.js.map +1 -0
  57. package/dist/cjs/providers/s3/utils/validateStorageOperationInputWithPrefix.js +32 -0
  58. package/dist/cjs/providers/s3/utils/validateStorageOperationInputWithPrefix.js.map +1 -0
  59. package/dist/esm/errors/types/validation.d.ts +7 -2
  60. package/dist/esm/errors/types/validation.mjs +22 -2
  61. package/dist/esm/errors/types/validation.mjs.map +1 -1
  62. package/dist/esm/index.d.ts +2 -2
  63. package/dist/esm/providers/s3/apis/copy.d.ts +22 -9
  64. package/dist/esm/providers/s3/apis/copy.mjs +2 -12
  65. package/dist/esm/providers/s3/apis/copy.mjs.map +1 -1
  66. package/dist/esm/providers/s3/apis/downloadData.d.ts +41 -7
  67. package/dist/esm/providers/s3/apis/downloadData.mjs +15 -39
  68. package/dist/esm/providers/s3/apis/downloadData.mjs.map +1 -1
  69. package/dist/esm/providers/s3/apis/getProperties.d.ts +18 -5
  70. package/dist/esm/providers/s3/apis/getProperties.mjs +2 -11
  71. package/dist/esm/providers/s3/apis/getProperties.mjs.map +1 -1
  72. package/dist/esm/providers/s3/apis/getUrl.d.ts +27 -7
  73. package/dist/esm/providers/s3/apis/getUrl.mjs +2 -18
  74. package/dist/esm/providers/s3/apis/getUrl.mjs.map +1 -1
  75. package/dist/esm/providers/s3/apis/internal/copy.d.ts +4 -2
  76. package/dist/esm/providers/s3/apis/internal/copy.mjs +41 -6
  77. package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
  78. package/dist/esm/providers/s3/apis/internal/getProperties.d.ts +2 -2
  79. package/dist/esm/providers/s3/apis/internal/getProperties.mjs +11 -6
  80. package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
  81. package/dist/esm/providers/s3/apis/internal/getUrl.d.ts +2 -2
  82. package/dist/esm/providers/s3/apis/internal/getUrl.mjs +10 -7
  83. package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
  84. package/dist/esm/providers/s3/apis/internal/list.d.ts +2 -2
  85. package/dist/esm/providers/s3/apis/internal/list.mjs +87 -16
  86. package/dist/esm/providers/s3/apis/internal/list.mjs.map +1 -1
  87. package/dist/esm/providers/s3/apis/internal/remove.d.ts +2 -2
  88. package/dist/esm/providers/s3/apis/internal/remove.mjs +21 -7
  89. package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
  90. package/dist/esm/providers/s3/apis/list.d.ts +39 -22
  91. package/dist/esm/providers/s3/apis/list.mjs +2 -2
  92. package/dist/esm/providers/s3/apis/list.mjs.map +1 -1
  93. package/dist/esm/providers/s3/apis/remove.d.ts +18 -5
  94. package/dist/esm/providers/s3/apis/remove.mjs +2 -9
  95. package/dist/esm/providers/s3/apis/remove.mjs.map +1 -1
  96. package/dist/esm/providers/s3/apis/server/copy.d.ts +27 -2
  97. package/dist/esm/providers/s3/apis/server/copy.mjs +2 -2
  98. package/dist/esm/providers/s3/apis/server/copy.mjs.map +1 -1
  99. package/dist/esm/providers/s3/apis/server/getProperties.d.ts +26 -2
  100. package/dist/esm/providers/s3/apis/server/getProperties.mjs +2 -2
  101. package/dist/esm/providers/s3/apis/server/getProperties.mjs.map +1 -1
  102. package/dist/esm/providers/s3/apis/server/getUrl.d.ts +40 -2
  103. package/dist/esm/providers/s3/apis/server/getUrl.mjs +2 -2
  104. package/dist/esm/providers/s3/apis/server/getUrl.mjs.map +1 -1
  105. package/dist/esm/providers/s3/apis/server/list.d.ts +41 -22
  106. package/dist/esm/providers/s3/apis/server/list.mjs +2 -2
  107. package/dist/esm/providers/s3/apis/server/list.mjs.map +1 -1
  108. package/dist/esm/providers/s3/apis/server/remove.d.ts +24 -2
  109. package/dist/esm/providers/s3/apis/server/remove.mjs +2 -2
  110. package/dist/esm/providers/s3/apis/server/remove.mjs.map +1 -1
  111. package/dist/esm/providers/s3/apis/uploadData/index.d.ts +64 -7
  112. package/dist/esm/providers/s3/apis/uploadData/index.mjs +4 -50
  113. package/dist/esm/providers/s3/apis/uploadData/index.mjs.map +1 -1
  114. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.d.ts +2 -2
  115. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.mjs +1 -1
  116. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.mjs.map +1 -1
  117. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadCache.d.ts +1 -1
  118. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadCache.mjs +8 -1
  119. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadCache.mjs.map +1 -1
  120. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.d.ts +4 -4
  121. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.mjs +30 -14
  122. package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.mjs.map +1 -1
  123. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.d.ts +3 -3
  124. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs +11 -5
  125. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs.map +1 -1
  126. package/dist/esm/providers/s3/index.d.ts +2 -2
  127. package/dist/esm/providers/s3/types/index.d.ts +3 -3
  128. package/dist/esm/providers/s3/types/inputs.d.ts +51 -11
  129. package/dist/esm/providers/s3/types/options.d.ts +41 -10
  130. package/dist/esm/providers/s3/types/outputs.d.ts +68 -13
  131. package/dist/esm/providers/s3/utils/client/utils/parsePayload.mjs +1 -1
  132. package/dist/esm/providers/s3/utils/client/utils/parsePayload.mjs.map +1 -1
  133. package/dist/esm/providers/s3/utils/constants.d.ts +3 -0
  134. package/dist/esm/providers/s3/utils/constants.mjs +4 -1
  135. package/dist/esm/providers/s3/utils/constants.mjs.map +1 -1
  136. package/dist/esm/providers/s3/utils/index.d.ts +3 -0
  137. package/dist/esm/providers/s3/utils/index.mjs +3 -0
  138. package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
  139. package/dist/esm/providers/s3/utils/isInputWithPath.d.ts +2 -0
  140. package/dist/esm/providers/s3/utils/isInputWithPath.mjs +8 -0
  141. package/dist/esm/providers/s3/utils/isInputWithPath.mjs.map +1 -0
  142. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.d.ts +2 -1
  143. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs +2 -1
  144. package/dist/esm/providers/s3/utils/resolveS3ConfigAndInput.mjs.map +1 -1
  145. package/dist/esm/providers/s3/utils/validateStorageOperationInput.d.ts +5 -0
  146. package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs +29 -0
  147. package/dist/esm/providers/s3/utils/validateStorageOperationInput.mjs.map +1 -0
  148. package/dist/esm/providers/s3/utils/validateStorageOperationInputWithPrefix.d.ts +5 -0
  149. package/dist/esm/providers/s3/utils/validateStorageOperationInputWithPrefix.mjs +30 -0
  150. package/dist/esm/providers/s3/utils/validateStorageOperationInputWithPrefix.mjs.map +1 -0
  151. package/dist/esm/types/index.d.ts +2 -2
  152. package/dist/esm/types/inputs.d.ts +41 -13
  153. package/dist/esm/types/options.d.ts +1 -0
  154. package/dist/esm/types/outputs.d.ts +26 -6
  155. package/package.json +107 -107
  156. package/src/errors/types/validation.ts +23 -2
  157. package/src/index.ts +16 -0
  158. package/src/providers/s3/apis/copy.ts +30 -11
  159. package/src/providers/s3/apis/downloadData.ts +78 -19
  160. package/src/providers/s3/apis/getProperties.ts +31 -8
  161. package/src/providers/s3/apis/getUrl.ts +37 -10
  162. package/src/providers/s3/apis/internal/copy.ts +89 -8
  163. package/src/providers/s3/apis/internal/getProperties.ts +27 -12
  164. package/src/providers/s3/apis/internal/getUrl.ts +28 -14
  165. package/src/providers/s3/apis/internal/list.ts +135 -29
  166. package/src/providers/s3/apis/internal/remove.ts +36 -13
  167. package/src/providers/s3/apis/list.ts +54 -26
  168. package/src/providers/s3/apis/remove.ts +28 -7
  169. package/src/providers/s3/apis/server/copy.ts +42 -5
  170. package/src/providers/s3/apis/server/getProperties.ts +41 -4
  171. package/src/providers/s3/apis/server/getUrl.ts +55 -4
  172. package/src/providers/s3/apis/server/list.ts +64 -32
  173. package/src/providers/s3/apis/server/remove.ts +39 -4
  174. package/src/providers/s3/apis/uploadData/index.ts +77 -8
  175. package/src/providers/s3/apis/uploadData/multipart/initialUpload.ts +4 -3
  176. package/src/providers/s3/apis/uploadData/multipart/uploadCache.ts +11 -2
  177. package/src/providers/s3/apis/uploadData/multipart/uploadHandlers.ts +50 -20
  178. package/src/providers/s3/apis/uploadData/putObjectJob.ts +23 -9
  179. package/src/providers/s3/index.ts +16 -0
  180. package/src/providers/s3/types/index.ts +37 -14
  181. package/src/providers/s3/types/inputs.ts +95 -26
  182. package/src/providers/s3/types/options.ts +73 -27
  183. package/src/providers/s3/types/outputs.ts +80 -13
  184. package/src/providers/s3/utils/client/utils/parsePayload.ts +1 -1
  185. package/src/providers/s3/utils/constants.ts +4 -0
  186. package/src/providers/s3/utils/index.ts +3 -0
  187. package/src/providers/s3/utils/isInputWithPath.ts +13 -0
  188. package/src/providers/s3/utils/resolveS3ConfigAndInput.ts +3 -2
  189. package/src/providers/s3/utils/validateStorageOperationInput.ts +39 -0
  190. package/src/providers/s3/utils/validateStorageOperationInputWithPrefix.ts +46 -0
  191. package/src/types/index.ts +16 -8
  192. package/src/types/inputs.ts +73 -20
  193. package/src/types/options.ts +1 -0
  194. package/src/types/outputs.ts +29 -6
@@ -1 +1 @@
1
- {"version":3,"file":"uploadCache.js","sources":["../../../../../../../src/providers/s3/apis/uploadData/multipart/uploadCache.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.removeCachedUpload = exports.cacheMultipartUpload = exports.getUploadsCacheKey = exports.findCachedUploadParts = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst constants_1 = require(\"../../../utils/constants\");\nconst client_1 = require(\"../../../utils/client\");\nconst utils_1 = require(\"../../../../../utils\");\nconst ONE_HOUR = 1000 * 60 * 60;\n/**\n * Find the cached multipart upload id and get the parts that have been uploaded\n * with ListParts API. If the cached upload is expired(1 hour), return null.\n */\nconst findCachedUploadParts = async ({ cacheKey, s3Config, bucket, finalKey, }) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n if (!cachedUploads[cacheKey] ||\n cachedUploads[cacheKey].lastTouched < Date.now() - ONE_HOUR // Uploads are cached for 1 hour\n ) {\n return null;\n }\n const cachedUpload = cachedUploads[cacheKey];\n cachedUpload.lastTouched = Date.now();\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n try {\n const { Parts = [] } = await (0, client_1.listParts)(s3Config, {\n Bucket: bucket,\n Key: finalKey,\n UploadId: cachedUpload.uploadId,\n });\n return {\n parts: Parts,\n uploadId: cachedUpload.uploadId,\n };\n }\n catch (e) {\n utils_1.logger.debug('failed to list cached parts, removing cached upload.');\n await (0, exports.removeCachedUpload)(cacheKey);\n return null;\n }\n};\nexports.findCachedUploadParts = findCachedUploadParts;\nconst listCachedUploadTasks = async (kvStorage) => {\n try {\n return JSON.parse((await kvStorage.getItem(constants_1.UPLOADS_STORAGE_KEY)) ?? '{}');\n }\n catch (e) {\n utils_1.logger.debug('failed to parse cached uploads record.');\n return {};\n }\n};\n/**\n * Get the cache key of a multipart upload. Data source cached by different: size, content type, bucket, access level,\n * key. If the data source is a File instance, the upload is additionally indexed by file name and last modified time.\n * So the library always created a new multipart upload if the file is modified.\n */\nconst getUploadsCacheKey = ({ file, size, contentType, bucket, accessLevel, key, }) => {\n const resolvedContentType = contentType ?? file?.type ?? 'application/octet-stream';\n const levelStr = accessLevel === 'guest' ? 'public' : accessLevel;\n const baseId = `${size}_${resolvedContentType}_${bucket}_${levelStr}_${key}`;\n if (file) {\n return `${file.name}_${file.lastModified}_${baseId}`;\n }\n else {\n return baseId;\n }\n};\nexports.getUploadsCacheKey = getUploadsCacheKey;\nconst cacheMultipartUpload = async (cacheKey, fileMetadata) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n cachedUploads[cacheKey] = {\n ...fileMetadata,\n lastTouched: Date.now(),\n };\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n};\nexports.cacheMultipartUpload = cacheMultipartUpload;\nconst removeCachedUpload = async (cacheKey) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n delete cachedUploads[cacheKey];\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n};\nexports.removeCachedUpload = removeCachedUpload;\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,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AAChI,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAChD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAChC;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,KAAK;AACnF,IAAI,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC7E,IAAI,IAAI,CAAC,aAAa,CAAC,QAA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K,CAAC;AACN,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,MAAM,kBAAkB,GAAG,OAAO,QAAQ,KAAK;AAC/C,IAAI,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC7E,IAAI,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnC,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
1
+ {"version":3,"file":"uploadCache.js","sources":["../../../../../../../src/providers/s3/apis/uploadData/multipart/uploadCache.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.removeCachedUpload = exports.cacheMultipartUpload = exports.getUploadsCacheKey = exports.findCachedUploadParts = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst constants_1 = require(\"../../../utils/constants\");\nconst client_1 = require(\"../../../utils/client\");\nconst utils_1 = require(\"../../../../../utils\");\nconst ONE_HOUR = 1000 * 60 * 60;\n/**\n * Find the cached multipart upload id and get the parts that have been uploaded\n * with ListParts API. If the cached upload is expired(1 hour), return null.\n */\nconst findCachedUploadParts = async ({ cacheKey, s3Config, bucket, finalKey, }) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n if (!cachedUploads[cacheKey] ||\n cachedUploads[cacheKey].lastTouched < Date.now() - ONE_HOUR // Uploads are cached for 1 hour\n ) {\n return null;\n }\n const cachedUpload = cachedUploads[cacheKey];\n cachedUpload.lastTouched = Date.now();\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n try {\n const { Parts = [] } = await (0, client_1.listParts)(s3Config, {\n Bucket: bucket,\n Key: finalKey,\n UploadId: cachedUpload.uploadId,\n });\n return {\n parts: Parts,\n uploadId: cachedUpload.uploadId,\n };\n }\n catch (e) {\n utils_1.logger.debug('failed to list cached parts, removing cached upload.');\n await (0, exports.removeCachedUpload)(cacheKey);\n return null;\n }\n};\nexports.findCachedUploadParts = findCachedUploadParts;\nconst listCachedUploadTasks = async (kvStorage) => {\n try {\n return JSON.parse((await kvStorage.getItem(constants_1.UPLOADS_STORAGE_KEY)) ?? '{}');\n }\n catch (e) {\n utils_1.logger.debug('failed to parse cached uploads record.');\n return {};\n }\n};\n/**\n * Get the cache key of a multipart upload. Data source cached by different: size, content type, bucket, access level,\n * key. If the data source is a File instance, the upload is additionally indexed by file name and last modified time.\n * So the library always created a new multipart upload if the file is modified.\n */\nconst getUploadsCacheKey = ({ file, size, contentType, bucket, accessLevel, key, }) => {\n let levelStr;\n const resolvedContentType = contentType ?? file?.type ?? 'application/octet-stream';\n // If no access level is defined, we're using custom gen2 access rules\n if (accessLevel === undefined) {\n levelStr = 'custom';\n }\n else {\n levelStr = accessLevel === 'guest' ? 'public' : accessLevel;\n }\n const baseId = `${size}_${resolvedContentType}_${bucket}_${levelStr}_${key}`;\n if (file) {\n return `${file.name}_${file.lastModified}_${baseId}`;\n }\n else {\n return baseId;\n }\n};\nexports.getUploadsCacheKey = getUploadsCacheKey;\nconst cacheMultipartUpload = async (cacheKey, fileMetadata) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n cachedUploads[cacheKey] = {\n ...fileMetadata,\n lastTouched: Date.now(),\n };\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n};\nexports.cacheMultipartUpload = cacheMultipartUpload;\nconst removeCachedUpload = async (cacheKey) => {\n const cachedUploads = await listCachedUploadTasks(core_1.defaultStorage);\n delete cachedUploads[cacheKey];\n await core_1.defaultStorage.setItem(constants_1.UPLOADS_STORAGE_KEY, JSON.stringify(cachedUploads));\n};\nexports.removeCachedUpload = removeCachedUpload;\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,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AAChI,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAChD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAChC;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,KAAK;AACnF,IAAI,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC7E,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;AAChC,QAAQ,aAAa,CAAC,QAAQ,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ;AACnE,MAAM;AACN,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjD,IAAI,YAAY,CAAC,WAAW,G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AS,CAAC,aAAa,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,MAAM,kBAAkB,GAAG,OAAO,QAAQ,KAAK;AAC/C,IAAI,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAC7E,IAAI,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnC,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -24,34 +24,48 @@ const getDataChunker_1 = require("./getDataChunker");
24
24
  *
25
25
  * @internal
26
26
  */
27
- const getMultipartUploadHandlers = ({ options: uploadDataOptions, key, data }, size) => {
27
+ const getMultipartUploadHandlers = (uploadDataInput, size) => {
28
28
  let resolveCallback;
29
29
  let rejectCallback;
30
30
  let inProgressUpload;
31
31
  let resolvedS3Config;
32
32
  let abortController;
33
+ let resolvedAccessLevel;
33
34
  let resolvedBucket;
34
35
  let resolvedKeyPrefix;
36
+ let resolvedIdentityId;
35
37
  let uploadCacheKey;
38
+ let finalKey;
36
39
  // Special flag that differentiates HTTP requests abort error caused by pause() from ones caused by cancel().
37
40
  // The former one should NOT cause the upload job to throw, but cancels any pending HTTP requests.
38
41
  // This should be replaced by a special abort reason. However,the support of this API is lagged behind.
39
42
  let isAbortSignalFromPause = false;
40
43
  const startUpload = async () => {
44
+ const { options: uploadDataOptions, data } = uploadDataInput;
41
45
  const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);
42
- resolvedS3Config = resolvedS3Options.s3Config;
43
- resolvedBucket = resolvedS3Options.bucket;
44
- resolvedKeyPrefix = resolvedS3Options.keyPrefix;
45
46
  abortController = new AbortController();
46
47
  isAbortSignalFromPause = false;
47
- const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, accessLevel, onProgress, } = uploadDataOptions ?? {};
48
+ resolvedS3Config = resolvedS3Options.s3Config;
49
+ resolvedBucket = resolvedS3Options.bucket;
50
+ resolvedIdentityId = resolvedS3Options.identityId;
51
+ const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, resolvedIdentityId);
52
+ const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};
53
+ finalKey = objectKey;
54
+ // Resolve "key" specific options
55
+ if (inputType === constants_1.STORAGE_INPUT_KEY) {
56
+ const accessLevel = uploadDataOptions
57
+ ?.accessLevel;
58
+ resolvedKeyPrefix = resolvedS3Options.keyPrefix;
59
+ finalKey = resolvedKeyPrefix + objectKey;
60
+ resolvedAccessLevel = resolveAccessLevel(accessLevel);
61
+ }
48
62
  if (!inProgressUpload) {
49
63
  const { uploadId, cachedParts } = await (0, initialUpload_1.loadOrCreateMultipartUpload)({
50
64
  s3Config: resolvedS3Config,
51
- accessLevel: resolveAccessLevel(accessLevel),
65
+ accessLevel: resolvedAccessLevel,
52
66
  bucket: resolvedBucket,
53
67
  keyPrefix: resolvedKeyPrefix,
54
- key,
68
+ key: objectKey,
55
69
  contentType,
56
70
  contentDisposition,
57
71
  contentEncoding,
@@ -65,15 +79,14 @@ const getMultipartUploadHandlers = ({ options: uploadDataOptions, key, data }, s
65
79
  completedParts: cachedParts,
66
80
  };
67
81
  }
68
- const finalKey = resolvedKeyPrefix + key;
69
82
  uploadCacheKey = size
70
83
  ? (0, uploadCache_1.getUploadsCacheKey)({
71
84
  file: data instanceof File ? data : undefined,
72
- accessLevel: resolveAccessLevel(uploadDataOptions?.accessLevel),
85
+ accessLevel: resolvedAccessLevel,
73
86
  contentType: uploadDataOptions?.contentType,
74
87
  bucket: resolvedBucket,
75
88
  size,
76
- key,
89
+ key: objectKey,
77
90
  })
78
91
  : undefined;
79
92
  const dataChunker = (0, getDataChunker_1.getDataChunker)(data, size);
@@ -131,12 +144,14 @@ const getMultipartUploadHandlers = ({ options: uploadDataOptions, key, data }, s
131
144
  if (uploadCacheKey) {
132
145
  await (0, uploadCache_1.removeCachedUpload)(uploadCacheKey);
133
146
  }
134
- return {
135
- key,
147
+ const result = {
136
148
  eTag,
137
149
  contentType,
138
150
  metadata,
139
151
  };
152
+ return inputType === constants_1.STORAGE_INPUT_KEY
153
+ ? { key: objectKey, ...result }
154
+ : { path: objectKey, ...result };
140
155
  };
141
156
  const startUploadWithResumability = () => startUpload()
142
157
  .then(resolveCallback)
@@ -173,7 +188,7 @@ const getMultipartUploadHandlers = ({ options: uploadDataOptions, key, data }, s
173
188
  // 3. clear multipart upload on server side.
174
189
  await (0, client_1.abortMultipartUpload)(resolvedS3Config, {
175
190
  Bucket: resolvedBucket,
176
- Key: resolvedKeyPrefix + key,
191
+ Key: finalKey,
177
192
  UploadId: inProgressUpload?.uploadId,
178
193
  });
179
194
  };
@@ -1 +1 @@
1
- {"version":3,"file":"uploadHandlers.js","sources":["../../../../../../../src/providers/s3/apis/uploadData/multipart/uploadHandlers.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.getMultipartUploadHandlers = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../utils\");\nconst constants_1 = require(\"../../../utils/constants\");\nconst StorageError_1 = require(\"../../../../../errors/StorageError\");\nconst CanceledError_1 = require(\"../../../../../errors/CanceledError\");\nconst client_1 = require(\"../../../utils/client\");\nconst userAgent_1 = require(\"../../../utils/userAgent\");\nconst utils_3 = require(\"../../../../../utils\");\nconst uploadPartExecutor_1 = require(\"./uploadPartExecutor\");\nconst uploadCache_1 = require(\"./uploadCache\");\nconst progressTracker_1 = require(\"./progressTracker\");\nconst initialUpload_1 = require(\"./initialUpload\");\nconst getDataChunker_1 = require(\"./getDataChunker\");\n/**\n * Create closure hiding the multipart upload implementation details and expose the upload job and control functions(\n * onPause, onResume, onCancel).\n *\n * @internal\n */\nconst getMultipartUploadHandlers = ({ options: uploadDataOptions, key, data }, size) => {\n let resolveCallback;\n let rejectCallback;\n let inProgressUpload;\n let resolvedS3Config;\n let abortController;\n let resolvedBucket;\n let resolvedKeyPrefix;\n let uploadCacheKey;\n // Special flag that differentiates HTTP requests abort error caused by pause() from ones caused by cancel().\n // The former one should NOT cause the upload job to throw, but cancels any pending HTTP requests.\n // This should be replaced by a special abort reason. However,the support of this API is lagged behind.\n let isAbortSignalFromPause = false;\n const startUpload = async () => {\n const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n resolvedS3Config = resolvedS3Options.s3Config;\n resolvedBucket = resolvedS3Options.bucket;\n resolvedKeyPrefix = resolvedS3Options.keyPrefix;\n abortController = new AbortController();\n isAbortSignalFromPause = false;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, accessLevel, onProgress, } = uploadDataOptions ?? {};\n if (!inProgressUpload) {\n const { uploadId, cachedParts } = await (0, initialUpload_1.loadOrCreateMultipartUpload)({\n s3Config: resolvedS3Config,\n accessLevel: resolveAccessLevel(accessLevel),\n bucket: resolvedBucket,\n keyPrefix: resolvedKeyPrefix,\n key,\n contentType,\n contentDisposition,\n contentEncoding,\n metadata,\n data,\n size,\n abortSignal: abortController.signal,\n });\n inProgressUpload = {\n uploadId,\n completedParts: cachedParts,\n };\n }\n const finalKey = resolvedKeyPrefix + key;\n uploadCacheKey = size\n ? (0, uploadCache_1.getUploadsCacheKey)({\n file: data instanceof File ? data : undefined,\n accessLevel: resolveAccessLevel(uploadDataOptions?.accessLevel),\n contentType: uploadDataOptions?.contentType,\n bucket: resolvedBucket,\n size,\n key,\n })\n : undefined;\n const dataChunker = (0, getDataChunker_1.getDataChunker)(data, size);\n const completedPartNumberSet = new Set(inProgressUpload.completedParts.map(({ PartNumber }) => PartNumber));\n const onPartUploadCompletion = (partNumber, eTag) => {\n inProgressUpload?.completedParts.push({\n PartNumber: partNumber,\n ETag: eTag,\n });\n };\n const concurrentUploadsProgressTracker = (0, progressTracker_1.getConcurrentUploadsProgressTracker)({\n size,\n onProgress,\n });\n const concurrentUploadPartExecutors = [];\n for (let index = 0; index < constants_1.DEFAULT_QUEUE_SIZE; index++) {\n concurrentUploadPartExecutors.push((0, uploadPartExecutor_1.uploadPartExecutor)({\n dataChunkerGenerator: dataChunker,\n completedPartNumberSet,\n s3Config: resolvedS3Config,\n abortSignal: abortController.signal,\n bucket: resolvedBucket,\n finalKey,\n uploadId: inProgressUpload.uploadId,\n onPartUploadCompletion,\n onProgress: concurrentUploadsProgressTracker.getOnProgressListener(),\n isObjectLockEnabled: resolvedS3Options.isObjectLockEnabled,\n }));\n }\n await Promise.all(concurrentUploadPartExecutors);\n const { ETag: eTag } = await (0, client_1.completeMultipartUpload)({\n ...resolvedS3Config,\n abortSignal: abortController.signal,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: resolvedBucket,\n Key: finalKey,\n UploadId: inProgressUpload.uploadId,\n MultipartUpload: {\n Parts: inProgressUpload.completedParts.sort((partA, partB) => partA.PartNumber - partB.PartNumber),\n },\n });\n if (size) {\n const { ContentLength: uploadedObjectSize } = await (0, client_1.headObject)(resolvedS3Config, {\n Bucket: resolvedBucket,\n Key: finalKey,\n });\n if (uploadedObjectSize && uploadedObjectSize !== size) {\n throw new StorageError_1.StorageError({\n name: 'Error',\n message: `Upload failed. Expected object size ${size}, but got ${uploadedObjectSize}.`,\n });\n }\n }\n if (uploadCacheKey) {\n await (0, uploadCache_1.removeCachedUpload)(uploadCacheKey);\n }\n return {\n key,\n eTag,\n contentType,\n metadata,\n };\n };\n const startUploadWithResumability = () => startUpload()\n .then(resolveCallback)\n .catch(error => {\n const abortSignal = abortController?.signal;\n if (abortSignal?.aborted && isAbortSignalFromPause) {\n utils_3.logger.debug('upload paused.');\n }\n else {\n // Uncaught errors should be exposed to the users.\n rejectCallback(error);\n }\n });\n const multipartUploadJob = () => new Promise((resolve, reject) => {\n resolveCallback = resolve;\n rejectCallback = reject;\n startUploadWithResumability();\n });\n const onPause = () => {\n isAbortSignalFromPause = true;\n abortController?.abort();\n };\n const onResume = () => {\n startUploadWithResumability();\n };\n const onCancel = (message) => {\n // 1. abort in-flight API requests\n abortController?.abort(message);\n const cancelUpload = async () => {\n // 2. clear upload cache.\n if (uploadCacheKey) {\n await (0, uploadCache_1.removeCachedUpload)(uploadCacheKey);\n }\n // 3. clear multipart upload on server side.\n await (0, client_1.abortMultipartUpload)(resolvedS3Config, {\n Bucket: resolvedBucket,\n Key: resolvedKeyPrefix + key,\n UploadId: inProgressUpload?.uploadId,\n });\n };\n cancelUpload().catch(e => {\n utils_3.logger.debug('error when cancelling upload task.', e);\n });\n rejectCallback(\n // Internal error that should not be exposed to the users. They should use isCancelError() to check if\n // the error is caused by cancel().\n new CanceledError_1.CanceledError(message ? { message } : undefined));\n };\n return {\n multipartUploadJob,\n onPause,\n onResume,\n onCancel,\n };\n};\nexports.getMultipartUploadHandlers = getMultipartUploadHandlers;\nconst resolveAccessLevel = (accessLevel) => accessLevel ??\n core_1.Amplify.libraryOptions.Storage?.S3?.defaultAccessLevel ??\n constants_1.DEFAULT_ACCESS_LEVEL;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO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":3,"file":"uploadHandlers.js","sources":["../../../../../../../src/providers/s3/apis/uploadData/multipart/uploadHandlers.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.getMultipartUploadHandlers = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../../utils\");\nconst constants_1 = require(\"../../../utils/constants\");\nconst StorageError_1 = require(\"../../../../../errors/StorageError\");\nconst CanceledError_1 = require(\"../../../../../errors/CanceledError\");\nconst client_1 = require(\"../../../utils/client\");\nconst userAgent_1 = require(\"../../../utils/userAgent\");\nconst utils_3 = require(\"../../../../../utils\");\nconst uploadPartExecutor_1 = require(\"./uploadPartExecutor\");\nconst uploadCache_1 = require(\"./uploadCache\");\nconst progressTracker_1 = require(\"./progressTracker\");\nconst initialUpload_1 = require(\"./initialUpload\");\nconst getDataChunker_1 = require(\"./getDataChunker\");\n/**\n * Create closure hiding the multipart upload implementation details and expose the upload job and control functions(\n * onPause, onResume, onCancel).\n *\n * @internal\n */\nconst getMultipartUploadHandlers = (uploadDataInput, size) => {\n let resolveCallback;\n let rejectCallback;\n let inProgressUpload;\n let resolvedS3Config;\n let abortController;\n let resolvedAccessLevel;\n let resolvedBucket;\n let resolvedKeyPrefix;\n let resolvedIdentityId;\n let uploadCacheKey;\n let finalKey;\n // Special flag that differentiates HTTP requests abort error caused by pause() from ones caused by cancel().\n // The former one should NOT cause the upload job to throw, but cancels any pending HTTP requests.\n // This should be replaced by a special abort reason. However,the support of this API is lagged behind.\n let isAbortSignalFromPause = false;\n const startUpload = async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n abortController = new AbortController();\n isAbortSignalFromPause = false;\n resolvedS3Config = resolvedS3Options.s3Config;\n resolvedBucket = resolvedS3Options.bucket;\n resolvedIdentityId = resolvedS3Options.identityId;\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, resolvedIdentityId);\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n finalKey = objectKey;\n // Resolve \"key\" specific options\n if (inputType === constants_1.STORAGE_INPUT_KEY) {\n const accessLevel = uploadDataOptions\n ?.accessLevel;\n resolvedKeyPrefix = resolvedS3Options.keyPrefix;\n finalKey = resolvedKeyPrefix + objectKey;\n resolvedAccessLevel = resolveAccessLevel(accessLevel);\n }\n if (!inProgressUpload) {\n const { uploadId, cachedParts } = await (0, initialUpload_1.loadOrCreateMultipartUpload)({\n s3Config: resolvedS3Config,\n accessLevel: resolvedAccessLevel,\n bucket: resolvedBucket,\n keyPrefix: resolvedKeyPrefix,\n key: objectKey,\n contentType,\n contentDisposition,\n contentEncoding,\n metadata,\n data,\n size,\n abortSignal: abortController.signal,\n });\n inProgressUpload = {\n uploadId,\n completedParts: cachedParts,\n };\n }\n uploadCacheKey = size\n ? (0, uploadCache_1.getUploadsCacheKey)({\n file: data instanceof File ? data : undefined,\n accessLevel: resolvedAccessLevel,\n contentType: uploadDataOptions?.contentType,\n bucket: resolvedBucket,\n size,\n key: objectKey,\n })\n : undefined;\n const dataChunker = (0, getDataChunker_1.getDataChunker)(data, size);\n const completedPartNumberSet = new Set(inProgressUpload.completedParts.map(({ PartNumber }) => PartNumber));\n const onPartUploadCompletion = (partNumber, eTag) => {\n inProgressUpload?.completedParts.push({\n PartNumber: partNumber,\n ETag: eTag,\n });\n };\n const concurrentUploadsProgressTracker = (0, progressTracker_1.getConcurrentUploadsProgressTracker)({\n size,\n onProgress,\n });\n const concurrentUploadPartExecutors = [];\n for (let index = 0; index < constants_1.DEFAULT_QUEUE_SIZE; index++) {\n concurrentUploadPartExecutors.push((0, uploadPartExecutor_1.uploadPartExecutor)({\n dataChunkerGenerator: dataChunker,\n completedPartNumberSet,\n s3Config: resolvedS3Config,\n abortSignal: abortController.signal,\n bucket: resolvedBucket,\n finalKey,\n uploadId: inProgressUpload.uploadId,\n onPartUploadCompletion,\n onProgress: concurrentUploadsProgressTracker.getOnProgressListener(),\n isObjectLockEnabled: resolvedS3Options.isObjectLockEnabled,\n }));\n }\n await Promise.all(concurrentUploadPartExecutors);\n const { ETag: eTag } = await (0, client_1.completeMultipartUpload)({\n ...resolvedS3Config,\n abortSignal: abortController.signal,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: resolvedBucket,\n Key: finalKey,\n UploadId: inProgressUpload.uploadId,\n MultipartUpload: {\n Parts: inProgressUpload.completedParts.sort((partA, partB) => partA.PartNumber - partB.PartNumber),\n },\n });\n if (size) {\n const { ContentLength: uploadedObjectSize } = await (0, client_1.headObject)(resolvedS3Config, {\n Bucket: resolvedBucket,\n Key: finalKey,\n });\n if (uploadedObjectSize && uploadedObjectSize !== size) {\n throw new StorageError_1.StorageError({\n name: 'Error',\n message: `Upload failed. Expected object size ${size}, but got ${uploadedObjectSize}.`,\n });\n }\n }\n if (uploadCacheKey) {\n await (0, uploadCache_1.removeCachedUpload)(uploadCacheKey);\n }\n const result = {\n eTag,\n contentType,\n metadata,\n };\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n };\n const startUploadWithResumability = () => startUpload()\n .then(resolveCallback)\n .catch(error => {\n const abortSignal = abortController?.signal;\n if (abortSignal?.aborted && isAbortSignalFromPause) {\n utils_3.logger.debug('upload paused.');\n }\n else {\n // Uncaught errors should be exposed to the users.\n rejectCallback(error);\n }\n });\n const multipartUploadJob = () => new Promise((resolve, reject) => {\n resolveCallback = resolve;\n rejectCallback = reject;\n startUploadWithResumability();\n });\n const onPause = () => {\n isAbortSignalFromPause = true;\n abortController?.abort();\n };\n const onResume = () => {\n startUploadWithResumability();\n };\n const onCancel = (message) => {\n // 1. abort in-flight API requests\n abortController?.abort(message);\n const cancelUpload = async () => {\n // 2. clear upload cache.\n if (uploadCacheKey) {\n await (0, uploadCache_1.removeCachedUpload)(uploadCacheKey);\n }\n // 3. clear multipart upload on server side.\n await (0, client_1.abortMultipartUpload)(resolvedS3Config, {\n Bucket: resolvedBucket,\n Key: finalKey,\n UploadId: inProgressUpload?.uploadId,\n });\n };\n cancelUpload().catch(e => {\n utils_3.logger.debug('error when cancelling upload task.', e);\n });\n rejectCallback(\n // Internal error that should not be exposed to the users. They should use isCancelError() to check if\n // the error is caused by cancel().\n new CanceledError_1.CanceledError(message ? { message } : undefined));\n };\n return {\n multipartUploadJob,\n onPause,\n onResume,\n onCancel,\n };\n};\nexports.getMultipartUploadHandlers = getMultipartUploadHandlers;\nconst resolveAccessLevel = (accessLevel) => accessLevel ??\n core_1.Amplify.libraryOptions.Storage?.S3?.defaultAccessLevel ??\n constants_1.DEFAULT_ACCESS_LEVEL;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,cAAc,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACrE,MAAM,eAAe,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACvE,MAAM,QAAQ,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC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I,OAAO;AACX,QAAQ,kBAAkB;AAC1B,QAAQ,OAAO;AACf,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;AAChE,MAAM,kBAAkB,GAAG,CAAC,WAAW,KAAK,WAAW;AACvD,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,EAAE,kBAAkB;AACjE,IAAI,WAAW,CAAC,oBAAoB;;"}
@@ -9,14 +9,17 @@ const utils_1 = require("@aws-amplify/core/internals/utils");
9
9
  const utils_2 = require("../../utils");
10
10
  const client_1 = require("../../utils/client");
11
11
  const userAgent_1 = require("../../utils/userAgent");
12
+ const constants_1 = require("../../utils/constants");
12
13
  /**
13
14
  * Get a function the returns a promise to call putObject API to S3.
14
15
  *
15
16
  * @internal
16
17
  */
17
- const putObjectJob = ({ options: uploadDataOptions, key, data }, abortSignal, totalLength) => async () => {
18
- const { bucket, keyPrefix, s3Config, isObjectLockEnabled } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);
19
- const finalKey = keyPrefix + key;
18
+ const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {
19
+ const { options: uploadDataOptions, data } = uploadDataInput;
20
+ const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);
21
+ const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, identityId);
22
+ const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
20
23
  const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};
21
24
  const { ETag: eTag, VersionId: versionId } = await (0, client_1.putObject)({
22
25
  ...s3Config,
@@ -35,14 +38,16 @@ const putObjectJob = ({ options: uploadDataOptions, key, data }, abortSignal, to
35
38
  ? await (0, utils_2.calculateContentMd5)(data)
36
39
  : undefined,
37
40
  });
38
- return {
39
- key,
41
+ const result = {
40
42
  eTag,
41
43
  versionId,
42
44
  contentType,
43
45
  metadata,
44
46
  size: totalLength,
45
47
  };
48
+ return inputType === constants_1.STORAGE_INPUT_KEY
49
+ ? { key: objectKey, ...result }
50
+ : { path: objectKey, ...result };
46
51
  };
47
52
  exports.putObjectJob = putObjectJob;
48
53
  //# sourceMappingURL=putObjectJob.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"putObjectJob.js","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.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.putObjectJob = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\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\");\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nconst putObjectJob = ({ options: uploadDataOptions, key, data }, abortSignal, totalLength) => async () => {\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n const finalKey = keyPrefix + key;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await (0, client_1.putObject)({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: contentDisposition,\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n ContentMD5: isObjectLockEnabled\n ? await (0, utils_2.calculateContentMd5)(data)\n : undefined,\n });\n return {\n key,\n eTag,\n versionId,\n contentType,\n metadata,\n size: totalLength,\n };\n};\nexports.putObjectJob = putObjectJob;\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,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;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,WAAW,KAAK,YAAY;AAC1G,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GAAG,MAAM,IAAI,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC/I,IAAI,MAAM,QAAQ,GAAG,SAAS,GAAG,GAAG,CAAC;AACrC,IAAI,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,GAAG,0BAA0B,EAAE,QAAQ,EAAE,UAAU,GAAG,GAAG,iBAAiB,IAAI,EAAE,CAAC;AAC7I,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,QAAQ,CAAC,SAAS,EAAE;AAC/E,QAAQ,GAAG,QAAQ;AACnB,QAAQ,WAAW;AACnB,QAAQ,gBAAgB,EAAE,UAAU;AACpC,QAAQ,cAAc,EAAE,IAAI,WAAW,CAAC,wBAAwB,EAAE,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC;AACnG,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,QAAQ,IAAI,EAAE,IAAI;AAClB,QAAQ,WAAW,EAAE,WAAW;AAChC,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,eAAe,EAAE,eAAe;AACxC,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,UAAU,EAAE,mBAAmB;AACvC,cAAc,MAAM,IAAI,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC;AAC1D,cAAc,SAAS;AACvB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,GAAG;AACX,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,WAAW;AACnB,QAAQ,QAAQ;AAChB,QAAQ,IAAI,EAAE,WAAW;AACzB,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
1
+ {"version":3,"file":"putObjectJob.js","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.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.putObjectJob = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\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 constants_1 = require(\"../../utils/constants\");\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nconst putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await (0, client_1.putObject)({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: contentDisposition,\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n ContentMD5: isObjectLockEnabled\n ? await (0, utils_2.calculateContentMd5)(data)\n : undefined,\n });\n const result = {\n eTag,\n versionId,\n contentType,\n metadata,\n size: totalLength,\n };\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\nexports.putObjectJob = putObjectJob;\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,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,WAAW,GAAG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eAAe,EAAE,eAAe;AACxC,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,UAAU,EAAE,mBAAmB;AACvC,cAAc,MAAM,IAAI,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC;AAC1D,cAAc,SAAS;AACvB,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,IAAI;AACZ,QAAQ,SAAS;AACjB,QAAQ,WAAW;AACnB,QAAQ,QAAQ;AAChB,QAAQ,IAAI,EAAE,WAAW;AACzB,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,YAAY,GAAG,YAAY;;"}
@@ -36,7 +36,7 @@ const parseXmlBody = async (response) => {
36
36
  return runtime_1.parser.parse(data);
37
37
  }
38
38
  catch (error) {
39
- throw new Error('Failed to parse XML response.');
39
+ throw new Error(`Failed to parse XML response: ${error}`);
40
40
  }
41
41
  }
42
42
  return {};
@@ -1 +1 @@
1
- {"version":3,"file":"parsePayload.js","sources":["../../../../../../../src/providers/s3/utils/client/utils/parsePayload.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.parseXmlBody = exports.parseXmlError = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst runtime_1 = require(\"../runtime\");\nconst parseXmlError = async (response) => {\n if (!response || response.statusCode < 300) {\n return;\n }\n const { statusCode } = response;\n const body = await (0, exports.parseXmlBody)(response);\n const code = body?.Code\n ? body.Code\n : statusCode === 404\n ? 'NotFound'\n : statusCode.toString();\n const message = body?.message ?? body?.Message ?? code;\n const error = new Error(message);\n return Object.assign(error, {\n name: code,\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n });\n};\nexports.parseXmlError = parseXmlError;\nconst parseXmlBody = async (response) => {\n if (!response.body) {\n // S3 can return 200 without a body indicating failure.\n throw new Error('S3 aborted request.');\n }\n const data = await response.body.text();\n if (data?.length > 0) {\n try {\n return runtime_1.parser.parse(data);\n }\n catch (error) {\n throw new Error('Failed to parse XML response.');\n }\n }\n return {};\n};\nexports.parseXmlBody = parseXmlBody;\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,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACtD,MAAM,kBAAkB,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;AACnF,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACxC,MAAM,aAAa,GAAG,OAAO,QAAQ,KAAK;AAC1C,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE;AAChD,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;AACpC,IAAI,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAC3D,IAAI,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI;AAC3B,UAAU,IAAI,CAAC,IAAI;AACnB,UAAU,UAAU,KAAK,GAAG;AAC5B,cAAc,UAAU;AACxB,cAAc,UAAU,CAAC,QAAQ,EAAE,CAAC;AACpC,IAAI,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC;AAC3D,IAAI,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AACrC,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;AAChC,QAAQ,IAAI,EAAE,IAAI;AAClB,QAAQ,SAAS,EAAE,IAAI,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;AAClE,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;AACtC,MAAM,YAAY,GAAG,OAAO,QAAQ,KAAK;AACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;AACxB;AACA,QAAQ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC/C,KAAK;AACL,IAAI,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5C,IAAI,IAAI,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE;AAC1B,QAAQ,IAAI;AACZ,YAAY,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChD,SAAS;AACT,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AAC7D,SAAS;AACT,KAAK;AACL,IAAI,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AACF,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
1
+ {"version":3,"file":"parsePayload.js","sources":["../../../../../../../src/providers/s3/utils/client/utils/parsePayload.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.parseXmlBody = exports.parseXmlError = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst runtime_1 = require(\"../runtime\");\nconst parseXmlError = async (response) => {\n if (!response || response.statusCode < 300) {\n return;\n }\n const { statusCode } = response;\n const body = await (0, exports.parseXmlBody)(response);\n const code = body?.Code\n ? body.Code\n : statusCode === 404\n ? 'NotFound'\n : statusCode.toString();\n const message = body?.message ?? body?.Message ?? code;\n const error = new Error(message);\n return Object.assign(error, {\n name: code,\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n });\n};\nexports.parseXmlError = parseXmlError;\nconst parseXmlBody = async (response) => {\n if (!response.body) {\n // S3 can return 200 without a body indicating failure.\n throw new Error('S3 aborted request.');\n }\n const data = await response.body.text();\n if (data?.length > 0) {\n try {\n return runtime_1.parser.parse(data);\n }\n catch (error) {\n throw new Error(`Failed to parse XML response: ${error}`);\n }\n }\n return {};\n};\nexports.parseXmlBody = parseXmlBody;\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,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACtD,MAAM,kBAAkB,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;AACnF,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACxC,MAAM,aAAa,GAAG,OAAO,QAAQ,KAAK;AAC1C,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE;AAChD,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;AACpC,IAAI,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAC3D,IAAI,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI;AAC3B,UAAU,IAAI,CAAC,IAAI;AACnB,UAAU,UAAU,KAAK,GAAG;AAC5B,cAAc,UAAU;AACxB,cAAc,UAAU,CAAC,QAAQ,EAAE,CAAC;AACpC,IAAI,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC;AAC3D,IAAI,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AACrC,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;AAChC,QAAQ,IAAI,EAAE,IAAI;AAClB,QAAQ,SAAS,EAAE,IAAI,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;AAClE,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;AACtC,MAAM,YAAY,GAAG,OAAO,QAAQ,KAAK;AACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;AACxB;AACA,QAAQ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC/C,KAAK;AACL,IAAI,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5C,IAAI,IAAI,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE;AAC1B,QAAQ,IAAI;AACZ,YAAY,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChD,SAAS;AACT,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACtE,SAAS;AACT,KAAK;AACL,IAAI,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AACF,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
@@ -3,7 +3,7 @@
3
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
4
  // SPDX-License-Identifier: Apache-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UPLOADS_STORAGE_KEY = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.MAX_URL_EXPIRATION = exports.DEFAULT_PRESIGN_EXPIRATION = exports.DEFAULT_ACCESS_LEVEL = exports.LOCAL_TESTING_S3_ENDPOINT = void 0;
6
+ exports.STORAGE_INPUT_PATH = exports.STORAGE_INPUT_KEY = exports.STORAGE_INPUT_PREFIX = exports.UPLOADS_STORAGE_KEY = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.MAX_URL_EXPIRATION = exports.DEFAULT_PRESIGN_EXPIRATION = exports.DEFAULT_ACCESS_LEVEL = exports.LOCAL_TESTING_S3_ENDPOINT = void 0;
7
7
  exports.LOCAL_TESTING_S3_ENDPOINT = 'http://localhost:20005';
8
8
  exports.DEFAULT_ACCESS_LEVEL = 'guest';
9
9
  exports.DEFAULT_PRESIGN_EXPIRATION = 900;
@@ -16,4 +16,7 @@ exports.MAX_OBJECT_SIZE = 5 * TiB;
16
16
  exports.MAX_PARTS_COUNT = 10000;
17
17
  exports.DEFAULT_QUEUE_SIZE = 4;
18
18
  exports.UPLOADS_STORAGE_KEY = '__uploadInProgress';
19
+ exports.STORAGE_INPUT_PREFIX = 'prefix';
20
+ exports.STORAGE_INPUT_KEY = 'key';
21
+ exports.STORAGE_INPUT_PATH = 'path';
19
22
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../src/providers/s3/utils/constants.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.UPLOADS_STORAGE_KEY = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.MAX_URL_EXPIRATION = exports.DEFAULT_PRESIGN_EXPIRATION = exports.DEFAULT_ACCESS_LEVEL = exports.LOCAL_TESTING_S3_ENDPOINT = void 0;\nexports.LOCAL_TESTING_S3_ENDPOINT = 'http://localhost:20005';\nexports.DEFAULT_ACCESS_LEVEL = 'guest';\nexports.DEFAULT_PRESIGN_EXPIRATION = 900;\nexports.MAX_URL_EXPIRATION = 7 * 24 * 60 * 60 * 1000;\nconst MiB = 1024 * 1024;\nconst GiB = 1024 * MiB;\nconst TiB = 1024 * GiB;\nexports.DEFAULT_PART_SIZE = 5 * MiB;\nexports.MAX_OBJECT_SIZE = 5 * TiB;\nexports.MAX_PARTS_COUNT = 10000;\nexports.DEFAULT_QUEUE_SIZE = 4;\nexports.UPLOADS_STORAGE_KEY = '__uploadInProgress';\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC;AACvR,OAAO,CAAC,yBAAyB,GAAG,wBAAwB,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC;AACvC,OAAO,CAAC,0BAA0B,GAAG,GAAG,CAAC;AACzC,OAAO,CAAC,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrD,MAAM,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACxB,MAAM,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AACvB,OAAO,CAAC,iBAAiB,GAAG,CAAC,GAAG,GAAG,CAAC;AACpC,OAAO,CAAC,eAAe,GAAG,CAAC,GAAG,GAAG,CAAC;AAClC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;AAChC,OAAO,CAAC,kBAAkB,GAAG,CAAC,CAAC;AAC/B,OAAO,CAAC,mBAAmB,GAAG,oBAAoB;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/providers/s3/utils/constants.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.STORAGE_INPUT_PATH = exports.STORAGE_INPUT_KEY = exports.STORAGE_INPUT_PREFIX = exports.UPLOADS_STORAGE_KEY = exports.DEFAULT_QUEUE_SIZE = exports.MAX_PARTS_COUNT = exports.MAX_OBJECT_SIZE = exports.DEFAULT_PART_SIZE = exports.MAX_URL_EXPIRATION = exports.DEFAULT_PRESIGN_EXPIRATION = exports.DEFAULT_ACCESS_LEVEL = exports.LOCAL_TESTING_S3_ENDPOINT = void 0;\nexports.LOCAL_TESTING_S3_ENDPOINT = 'http://localhost:20005';\nexports.DEFAULT_ACCESS_LEVEL = 'guest';\nexports.DEFAULT_PRESIGN_EXPIRATION = 900;\nexports.MAX_URL_EXPIRATION = 7 * 24 * 60 * 60 * 1000;\nconst MiB = 1024 * 1024;\nconst GiB = 1024 * MiB;\nconst TiB = 1024 * GiB;\nexports.DEFAULT_PART_SIZE = 5 * MiB;\nexports.MAX_OBJECT_SIZE = 5 * TiB;\nexports.MAX_PARTS_COUNT = 10000;\nexports.DEFAULT_QUEUE_SIZE = 4;\nexports.UPLOADS_STORAGE_KEY = '__uploadInProgress';\nexports.STORAGE_INPUT_PREFIX = 'prefix';\nexports.STORAGE_INPUT_KEY = 'key';\nexports.STORAGE_INPUT_PATH = 'path';\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,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2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createUploadTask = exports.createDownloadTask = exports.resolveS3ConfigAndInput = exports.calculateContentMd5 = void 0;
6
+ exports.isInputWithPath = exports.validateStorageOperationInputWithPrefix = exports.validateStorageOperationInput = exports.createUploadTask = exports.createDownloadTask = exports.resolveS3ConfigAndInput = exports.calculateContentMd5 = void 0;
7
7
  var md5_1 = require("./md5");
8
8
  Object.defineProperty(exports, "calculateContentMd5", { enumerable: true, get: function () { return md5_1.calculateContentMd5; } });
9
9
  var resolveS3ConfigAndInput_1 = require("./resolveS3ConfigAndInput");
@@ -11,4 +11,10 @@ Object.defineProperty(exports, "resolveS3ConfigAndInput", { enumerable: true, ge
11
11
  var transferTask_1 = require("./transferTask");
12
12
  Object.defineProperty(exports, "createDownloadTask", { enumerable: true, get: function () { return transferTask_1.createDownloadTask; } });
13
13
  Object.defineProperty(exports, "createUploadTask", { enumerable: true, get: function () { return transferTask_1.createUploadTask; } });
14
+ var validateStorageOperationInput_1 = require("./validateStorageOperationInput");
15
+ Object.defineProperty(exports, "validateStorageOperationInput", { enumerable: true, get: function () { return validateStorageOperationInput_1.validateStorageOperationInput; } });
16
+ var validateStorageOperationInputWithPrefix_1 = require("./validateStorageOperationInputWithPrefix");
17
+ Object.defineProperty(exports, "validateStorageOperationInputWithPrefix", { enumerable: true, get: function () { return validateStorageOperationInputWithPrefix_1.validateStorageOperationInputWithPrefix; } });
18
+ var isInputWithPath_1 = require("./isInputWithPath");
19
+ Object.defineProperty(exports, "isInputWithPath", { enumerable: true, get: function () { return isInputWithPath_1.isInputWithPath; } });
14
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/providers/s3/utils/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.createUploadTask = exports.createDownloadTask = exports.resolveS3ConfigAndInput = exports.calculateContentMd5 = void 0;\nvar md5_1 = require(\"./md5\");\nObject.defineProperty(exports, \"calculateContentMd5\", { enumerable: true, get: function () { return md5_1.calculateContentMd5; } });\nvar resolveS3ConfigAndInput_1 = require(\"./resolveS3ConfigAndInput\");\nObject.defineProperty(exports, \"resolveS3ConfigAndInput\", { enumerable: true, get: function () { return resolveS3ConfigAndInput_1.resolveS3ConfigAndInput; } });\nvar transferTask_1 = require(\"./transferTask\");\nObject.defineProperty(exports, \"createDownloadTask\", { enumerable: true, get: function () { return transferTask_1.createDownloadTask; } });\nObject.defineProperty(exports, \"createUploadTask\", { enumerable: true, get: function () { return transferTask_1.createUploadTask; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AAC/H,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,KAAK,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC;AACpI,IAAI,yBAAyB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACrE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,yBAAyB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,yBAAyB,CAAC,uBAAuB,CAAC,EAAE,EAAE,CAAC,CAAC;AAChK,IAAI,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC/C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3I,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/providers/s3/utils/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.isInputWithPath = exports.validateStorageOperationInputWithPrefix = exports.validateStorageOperationInput = exports.createUploadTask = exports.createDownloadTask = exports.resolveS3ConfigAndInput = exports.calculateContentMd5 = void 0;\nvar md5_1 = require(\"./md5\");\nObject.defineProperty(exports, \"calculateContentMd5\", { enumerable: true, get: function () { return md5_1.calculateContentMd5; } });\nvar resolveS3ConfigAndInput_1 = require(\"./resolveS3ConfigAndInput\");\nObject.defineProperty(exports, \"resolveS3ConfigAndInput\", { enumerable: true, get: function () { return resolveS3ConfigAndInput_1.resolveS3ConfigAndInput; } });\nvar transferTask_1 = require(\"./transferTask\");\nObject.defineProperty(exports, \"createDownloadTask\", { enumerable: true, get: function () { return transferTask_1.createDownloadTask; } });\nObject.defineProperty(exports, \"createUploadTask\", { enumerable: true, get: function () { return transferTask_1.createUploadTask; } });\nvar validateStorageOperationInput_1 = require(\"./validateStorageOperationInput\");\nObject.defineProperty(exports, \"validateStorageOperationInput\", { enumerable: true, get: function () { return validateStorageOperationInput_1.validateStorageOperationInput; } });\nvar validateStorageOperationInputWithPrefix_1 = require(\"./validateStorageOperationInputWithPrefix\");\nObject.defineProperty(exports, \"validateStorageOperationInputWithPrefix\", { enumerable: true, get: function () { return validateStorageOperationInputWithPrefix_1.validateStorageOperationInputWithPrefix; } });\nvar isInputWithPath_1 = require(\"./isInputWithPath\");\nObject.defineProperty(exports, \"isInputWithPath\", { enumerable: true, get: function () { return isInputWithPath_1.isInputWithPath; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,uCAAuC,GAAG,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AACnP,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,KAAK,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC;AACpI,IAAI,yBAAyB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AACrE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,yBAAyB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,yBAAyB,CAAC,uBAAuB,CAAC,EAAE,EAAE,CAAC,CAAC;AAChK,IAAI,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC/C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3I,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;AACvI,IAAI,+BAA+B,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACjF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,+BAA+B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,+BAA+B,CAAC,6BAA6B,CAAC,EAAE,EAAE,CAAC,CAAC;AAClL,IAAI,yCAAyC,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AACrG,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,yCAAyC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,yCAAyC,CAAC,uCAAuC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChN,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC;;"}
@@ -0,0 +1,11 @@
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.isInputWithPath = void 0;
7
+ const isInputWithPath = (input) => {
8
+ return input.path !== undefined;
9
+ };
10
+ exports.isInputWithPath = isInputWithPath;
11
+ //# sourceMappingURL=isInputWithPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isInputWithPath.js","sources":["../../../../../src/providers/s3/utils/isInputWithPath.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.isInputWithPath = void 0;\nconst isInputWithPath = (input) => {\n return input.path !== undefined;\n};\nexports.isInputWithPath = isInputWithPath;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,eAAe,GAAG,CAAC,KAAK,KAAK;AACnC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AACpC,CAAC,CAAC;AACF,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
@@ -14,7 +14,7 @@ const constants_1 = require("./constants");
14
14
  * @param {AmplifyClassV6} amplify The Amplify instance.
15
15
  * @param {S3ApiOptions} apiOptions The input options for S3 provider.
16
16
  * @returns {Promise<ResolvedS3ConfigAndInput>} The resolved common input options for S3 API handlers.
17
- * @throws A {@link StorageError} with `error.name` from {@link StorageValidationErrorCode} indicating invalid
17
+ * @throws A `StorageError` with `error.name` from `StorageValidationErrorCode` indicating invalid
18
18
  * configurations or Amplify library options.
19
19
  *
20
20
  * @internal
@@ -51,6 +51,7 @@ const resolveS3ConfigAndInput = async (amplify, apiOptions) => {
51
51
  },
52
52
  bucket,
53
53
  keyPrefix,
54
+ identityId,
54
55
  isObjectLockEnabled,
55
56
  };
56
57
  };
@@ -1 +1 @@
1
- {"version":3,"file":"resolveS3ConfigAndInput.js","sources":["../../../../../src/providers/s3/utils/resolveS3ConfigAndInput.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.resolveS3ConfigAndInput = void 0;\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst resolvePrefix_1 = require(\"../../../utils/resolvePrefix\");\nconst constants_1 = require(\"./constants\");\n/**\n * resolve the common input options for S3 API handlers from Amplify configuration and library options.\n *\n * @param {AmplifyClassV6} amplify The Amplify instance.\n * @param {S3ApiOptions} apiOptions The input options for S3 provider.\n * @returns {Promise<ResolvedS3ConfigAndInput>} The resolved common input options for S3 API handlers.\n * @throws A {@link StorageError} with `error.name` from {@link StorageValidationErrorCode} indicating invalid\n * configurations or Amplify library options.\n *\n * @internal\n */\nconst resolveS3ConfigAndInput = async (amplify, apiOptions) => {\n // identityId is always cached in memory if forceRefresh is not set. So we can safely make calls here.\n const { credentials, identityId } = await amplify.Auth.fetchAuthSession({\n forceRefresh: false,\n });\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.StorageValidationErrorCode.NoCredentials);\n (0, assertValidationError_1.assertValidationError)(!!identityId, validation_1.StorageValidationErrorCode.NoIdentityId);\n const { bucket, region, dangerouslyConnectToHttpEndpointForTesting } = amplify.getConfig()?.Storage?.S3 ?? {};\n (0, assertValidationError_1.assertValidationError)(!!bucket, validation_1.StorageValidationErrorCode.NoBucket);\n (0, assertValidationError_1.assertValidationError)(!!region, validation_1.StorageValidationErrorCode.NoRegion);\n const { defaultAccessLevel, prefixResolver = resolvePrefix_1.resolvePrefix, isObjectLockEnabled, } = amplify.libraryOptions?.Storage?.S3 ?? {};\n const keyPrefix = await prefixResolver({\n accessLevel: apiOptions?.accessLevel ?? defaultAccessLevel ?? constants_1.DEFAULT_ACCESS_LEVEL,\n // use conditional assign to make tsc happy because StorageOptions is a union type that may not have targetIdentityId\n targetIdentityId: apiOptions?.accessLevel === 'protected'\n ? apiOptions?.targetIdentityId ?? identityId\n : identityId,\n });\n return {\n s3Config: {\n credentials,\n region,\n useAccelerateEndpoint: apiOptions?.useAccelerateEndpoint,\n ...(dangerouslyConnectToHttpEndpointForTesting\n ? {\n customEndpoint: constants_1.LOCAL_TESTING_S3_ENDPOINT,\n forcePathStyle: true,\n }\n : {}),\n },\n bucket,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AACnH,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AACnH,IAAI,MAAM,EAAE,kBAAkB,EAAE,cAAc,GAAG,eAAe,CAAC,aAAa,EAAE,mBAAmB,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC;AACnJ,IAAI,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC;AAC3C,QAAQ,WAAW,EAAE,UAAU,EAAE,WAAW,IAAI,kBAAkB,IAAI,WAAW,CAAC,oBAAoB;AACtG;AACA,QAAQ,gBAAgB,EAAE,UAAU,EAAE,WAAW,KAAK,WAAW;AACjE,cAAc,UAAU,EAAE,gBAAgB,IAAI,UAAU;AACxD,cAAc,UAAU;AACxB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,QAAQ,EAAE;AAClB,YAAY,WAAW;AACvB,YAAY,MAAM;AAClB,YAAY,qBAAqB,EAAE,UAAU,EAAE,qBAAqB;AACpE,YAAY,IAAI,0CAA0C;AAC1D,kBAAkB;AAClB,oBAAoB,cAAc,EAAE,WAAW,CAAC,yBAAyB;AACzE,oBAAoB,cAAc,EAAE,IAAI;AACxC,iBAAiB;AACjB,kBAAkB,EAAE;AACpB,SAAS;AACT,QAAQ,MAAM;AACd,QAAQ,SAAS;AACjB,QAAQ,mBAAmB;AAC3B,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
1
+ {"version":3,"file":"resolveS3ConfigAndInput.js","sources":["../../../../../src/providers/s3/utils/resolveS3ConfigAndInput.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.resolveS3ConfigAndInput = void 0;\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst resolvePrefix_1 = require(\"../../../utils/resolvePrefix\");\nconst constants_1 = require(\"./constants\");\n/**\n * resolve the common input options for S3 API handlers from Amplify configuration and library options.\n *\n * @param {AmplifyClassV6} amplify The Amplify instance.\n * @param {S3ApiOptions} apiOptions The input options for S3 provider.\n * @returns {Promise<ResolvedS3ConfigAndInput>} The resolved common input options for S3 API handlers.\n * @throws A `StorageError` with `error.name` from `StorageValidationErrorCode` indicating invalid\n * configurations or Amplify library options.\n *\n * @internal\n */\nconst resolveS3ConfigAndInput = async (amplify, apiOptions) => {\n // identityId is always cached in memory if forceRefresh is not set. So we can safely make calls here.\n const { credentials, identityId } = await amplify.Auth.fetchAuthSession({\n forceRefresh: false,\n });\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.StorageValidationErrorCode.NoCredentials);\n (0, assertValidationError_1.assertValidationError)(!!identityId, validation_1.StorageValidationErrorCode.NoIdentityId);\n const { bucket, region, dangerouslyConnectToHttpEndpointForTesting } = amplify.getConfig()?.Storage?.S3 ?? {};\n (0, assertValidationError_1.assertValidationError)(!!bucket, validation_1.StorageValidationErrorCode.NoBucket);\n (0, assertValidationError_1.assertValidationError)(!!region, validation_1.StorageValidationErrorCode.NoRegion);\n const { defaultAccessLevel, prefixResolver = resolvePrefix_1.resolvePrefix, isObjectLockEnabled, } = amplify.libraryOptions?.Storage?.S3 ?? {};\n const keyPrefix = await prefixResolver({\n accessLevel: apiOptions?.accessLevel ?? defaultAccessLevel ?? constants_1.DEFAULT_ACCESS_LEVEL,\n // use conditional assign to make tsc happy because StorageOptions is a union type that may not have targetIdentityId\n targetIdentityId: apiOptions?.accessLevel === 'protected'\n ? apiOptions?.targetIdentityId ?? identityId\n : identityId,\n });\n return {\n s3Config: {\n credentials,\n region,\n useAccelerateEndpoint: apiOptions?.useAccelerateEndpoint,\n ...(dangerouslyConnectToHttpEndpointForTesting\n ? {\n customEndpoint: constants_1.LOCAL_TESTING_S3_ENDPOINT,\n forcePathStyle: true,\n }\n : {}),\n },\n bucket,\n keyPrefix,\n identityId,\n isObjectLockEnabled,\n };\n};\nexports.resolveS3ConfigAndInput = resolveS3ConfigAndInput;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACzC,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,eAAe,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,uBAAuB,GAAG,OAAO,OAAO,EAAE,UAAU,KAAK;AAC/D;AACA,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC;AAC5E,QAAQ,YAAY,EAAE,KAAK;AAC3B,KAAK,CAAC,CAAC;AACP,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC;AAC7H,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAC3H,IAAI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,0CAA0C,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC;AAClH,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AACnH,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AACnH,IAAI,MAAM,EAAE,kBAAkB,EAAE,cAAc,GAAG,eAAe,CAAC,aAAa,EAAE,mBAAmB,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC;AACnJ,IAAI,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC;AAC3C,QAAQ,WAAW,EAAE,UAAU,EAAE,WAAW,IAAI,kBAAkB,IAAI,WAAW,CAAC,oBAAoB;AACtG;AACA,QAAQ,gBAAgB,EAAE,UAAU,EAAE,WAAW,KAAK,WAAW;AACjE,cAAc,UAAU,EAAE,gBAAgB,IAAI,UAAU;AACxD,cAAc,UAAU;AACxB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO;AACX,QAAQ,QAAQ,EAAE;AAClB,YAAY,WAAW;AACvB,YAAY,MAAM;AAClB,YAAY,qBAAqB,EAAE,UAAU,EAAE,qBAAqB;AACpE,YAAY,IAAI,0CAA0C;AAC1D,kBAAkB;AAClB,oBAAoB,cAAc,EAAE,WAAW,CAAC,yBAAyB;AACzE,oBAAoB,cAAc,EAAE,IAAI;AACxC,iBAAiB;AACjB,kBAAkB,EAAE;AACpB,SAAS;AACT,QAAQ,MAAM;AACd,QAAQ,SAAS;AACjB,QAAQ,UAAU;AAClB,QAAQ,mBAAmB;AAC3B,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,uBAAuB,GAAG,uBAAuB;;"}
@@ -0,0 +1,31 @@
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.validateStorageOperationInput = void 0;
7
+ const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
8
+ const validation_1 = require("../../../errors/types/validation");
9
+ const isInputWithPath_1 = require("./isInputWithPath");
10
+ const constants_1 = require("./constants");
11
+ const validateStorageOperationInput = (input, identityId) => {
12
+ (0, assertValidationError_1.assertValidationError)(
13
+ // Key present without a path
14
+ (!!input.key && !input.path) ||
15
+ // Path present without a key
16
+ (!input.key && !!input.path), validation_1.StorageValidationErrorCode.InvalidStorageOperationInput);
17
+ if ((0, isInputWithPath_1.isInputWithPath)(input)) {
18
+ const { path } = input;
19
+ const objectKey = typeof path === 'string' ? path : path({ identityId });
20
+ (0, assertValidationError_1.assertValidationError)(!objectKey.startsWith('/'), validation_1.StorageValidationErrorCode.InvalidStoragePathInput);
21
+ return {
22
+ inputType: constants_1.STORAGE_INPUT_PATH,
23
+ objectKey,
24
+ };
25
+ }
26
+ else {
27
+ return { inputType: constants_1.STORAGE_INPUT_KEY, objectKey: input.key };
28
+ }
29
+ };
30
+ exports.validateStorageOperationInput = validateStorageOperationInput;
31
+ //# sourceMappingURL=validateStorageOperationInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateStorageOperationInput.js","sources":["../../../../../src/providers/s3/utils/validateStorageOperationInput.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.validateStorageOperationInput = void 0;\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst isInputWithPath_1 = require(\"./isInputWithPath\");\nconst constants_1 = require(\"./constants\");\nconst validateStorageOperationInput = (input, identityId) => {\n (0, assertValidationError_1.assertValidationError)(\n // Key present without a path\n (!!input.key && !input.path) ||\n // Path present without a key\n (!input.key && !!input.path), validation_1.StorageValidationErrorCode.InvalidStorageOperationInput);\n if ((0, isInputWithPath_1.isInputWithPath)(input)) {\n const { path } = input;\n const objectKey = typeof path === 'string' ? path : path({ identityId });\n (0, assertValidationError_1.assertValidationError)(!objectKey.startsWith('/'), validation_1.StorageValidationErrorCode.InvalidStoragePathInput);\n return {\n inputType: constants_1.STORAGE_INPUT_PATH,\n objectKey,\n };\n }\n else {\n return { inputType: constants_1.STORAGE_INPUT_KEY, objectKey: input.key };\n }\n};\nexports.validateStorageOperationInput = validateStorageOperationInput;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,6BAA6B,GAAG,KAAK,CAAC,CAAC;AAC/C,MAAM,uBAAuB,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AACvF,MAAM,YAAY,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACjE,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACvD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C,MAAM,6BAA6B,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK;AAC7D,IAAI,IAAI,uBAAuB,CAAC,qBAAqB;AACrD;AACA,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI;AAC/B;AACA,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,0BAA0B,CAAC,4BAA4B,CAAC,CAAC;AAC5G,IAAI,IAAI,IAAI,iBAAiB,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE;AACvD,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AACjF,QAAQ,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;AACxJ,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,WAAW,CAAC,kBAAkB;AACrD,YAAY,SAAS;AACrB,SAAS,CAAC;AACV,KAAK;AACL,SAAS;AACT,QAAQ,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,iBAAiB,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AAClF,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,6BAA6B,GAAG,6BAA6B;;"}
@@ -0,0 +1,32 @@
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.validateStorageOperationInputWithPrefix = void 0;
7
+ const assertValidationError_1 = require("../../../errors/utils/assertValidationError");
8
+ const validation_1 = require("../../../errors/types/validation");
9
+ const constants_1 = require("./constants");
10
+ // Local assertion function with StorageOperationInputWithPrefixPath as Input
11
+ const _isInputWithPath = (input) => {
12
+ return input.path !== undefined;
13
+ };
14
+ const validateStorageOperationInputWithPrefix = (input, identityId) => {
15
+ // Validate prefix & path not present at the same time
16
+ (0, assertValidationError_1.assertValidationError)(!(input.prefix && input.path), validation_1.StorageValidationErrorCode.InvalidStorageOperationPrefixInput);
17
+ if (_isInputWithPath(input)) {
18
+ const { path } = input;
19
+ const objectKey = typeof path === 'string' ? path : path({ identityId });
20
+ // Assert on no leading slash in the path parameter
21
+ (0, assertValidationError_1.assertValidationError)(!objectKey.startsWith('/'), validation_1.StorageValidationErrorCode.InvalidStoragePathInput);
22
+ return {
23
+ inputType: constants_1.STORAGE_INPUT_PATH,
24
+ objectKey,
25
+ };
26
+ }
27
+ else {
28
+ return { inputType: constants_1.STORAGE_INPUT_PREFIX, objectKey: input.prefix ?? '' };
29
+ }
30
+ };
31
+ exports.validateStorageOperationInputWithPrefix = validateStorageOperationInputWithPrefix;
32
+ //# sourceMappingURL=validateStorageOperationInputWithPrefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateStorageOperationInputWithPrefix.js","sources":["../../../../../src/providers/s3/utils/validateStorageOperationInputWithPrefix.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.validateStorageOperationInputWithPrefix = void 0;\nconst assertValidationError_1 = require(\"../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../errors/types/validation\");\nconst constants_1 = require(\"./constants\");\n// Local assertion function with StorageOperationInputWithPrefixPath as Input\nconst _isInputWithPath = (input) => {\n return input.path !== undefined;\n};\nconst validateStorageOperationInputWithPrefix = (input, identityId) => {\n // Validate prefix & path not present at the same time\n (0, assertValidationError_1.assertValidationError)(!(input.prefix && input.path), validation_1.StorageValidationErrorCode.InvalidStorageOperationPrefixInput);\n if (_isInputWithPath(input)) {\n const { path } = input;\n const objectKey = typeof path === 'string' ? path : path({ identityId });\n // Assert on no leading slash in the path parameter\n (0, assertValidationError_1.assertValidationError)(!objectKey.startsWith('/'), validation_1.StorageValidationErrorCode.InvalidStoragePathInput);\n return {\n inputType: constants_1.STORAGE_INPUT_PATH,\n objectKey,\n };\n }\n else {\n return { inputType: constants_1.STORAGE_INPUT_PREFIX, objectKey: input.prefix ?? '' };\n }\n};\nexports.validateStorageOperationInputWithPrefix = validateStorageOperationInputWithPrefix;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,uCAAuC,GAAG,KA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StorageValidationErrorCode {
5
5
  NoKey = "NoKey",
6
6
  NoSourceKey = "NoSourceKey",
7
7
  NoDestinationKey = "NoDestinationKey",
8
+ NoSourcePath = "NoSourcePath",
9
+ NoDestinationPath = "NoDestinationPath",
8
10
  NoBucket = "NoBucket",
9
11
  NoRegion = "NoRegion",
10
- UrlExpirationMaxLimitExceed = "UrlExpirationMaxLimitExceed",
12
+ InvalidStorageOperationPrefixInput = "InvalidStorageOperationPrefixInput",
13
+ InvalidStorageOperationInput = "InvalidStorageOperationInput",
14
+ InvalidStoragePathInput = "InvalidStoragePathInput",
15
+ InvalidUploadSource = "InvalidUploadSource",
11
16
  ObjectIsTooLarge = "ObjectIsTooLarge",
12
- InvalidUploadSource = "InvalidUploadSource"
17
+ UrlExpirationMaxLimitExceed = "UrlExpirationMaxLimitExceed"
13
18
  }
14
19
  export declare const validationErrorMap: AmplifyErrorMap<StorageValidationErrorCode>;
@@ -7,11 +7,16 @@ var StorageValidationErrorCode;
7
7
  StorageValidationErrorCode["NoKey"] = "NoKey";
8
8
  StorageValidationErrorCode["NoSourceKey"] = "NoSourceKey";
9
9
  StorageValidationErrorCode["NoDestinationKey"] = "NoDestinationKey";
10
+ StorageValidationErrorCode["NoSourcePath"] = "NoSourcePath";
11
+ StorageValidationErrorCode["NoDestinationPath"] = "NoDestinationPath";
10
12
  StorageValidationErrorCode["NoBucket"] = "NoBucket";
11
13
  StorageValidationErrorCode["NoRegion"] = "NoRegion";
12
- StorageValidationErrorCode["UrlExpirationMaxLimitExceed"] = "UrlExpirationMaxLimitExceed";
13
- StorageValidationErrorCode["ObjectIsTooLarge"] = "ObjectIsTooLarge";
14
+ StorageValidationErrorCode["InvalidStorageOperationPrefixInput"] = "InvalidStorageOperationPrefixInput";
15
+ StorageValidationErrorCode["InvalidStorageOperationInput"] = "InvalidStorageOperationInput";
16
+ StorageValidationErrorCode["InvalidStoragePathInput"] = "InvalidStoragePathInput";
14
17
  StorageValidationErrorCode["InvalidUploadSource"] = "InvalidUploadSource";
18
+ StorageValidationErrorCode["ObjectIsTooLarge"] = "ObjectIsTooLarge";
19
+ StorageValidationErrorCode["UrlExpirationMaxLimitExceed"] = "UrlExpirationMaxLimitExceed";
15
20
  })(StorageValidationErrorCode || (StorageValidationErrorCode = {}));
16
21
  const validationErrorMap = {
17
22
  [StorageValidationErrorCode.NoCredentials]: {
@@ -29,6 +34,12 @@ const validationErrorMap = {
29
34
  [StorageValidationErrorCode.NoDestinationKey]: {
30
35
  message: 'Missing destination key in copy api call.',
31
36
  },
37
+ [StorageValidationErrorCode.NoSourcePath]: {
38
+ message: 'Missing source path in copy api call.',
39
+ },
40
+ [StorageValidationErrorCode.NoDestinationPath]: {
41
+ message: 'Missing destination path in copy api call.',
42
+ },
32
43
  [StorageValidationErrorCode.NoBucket]: {
33
44
  message: 'Missing bucket name while accessing object.',
34
45
  },
@@ -44,6 +55,15 @@ const validationErrorMap = {
44
55
  [StorageValidationErrorCode.InvalidUploadSource]: {
45
56
  message: 'Upload source type can only be a `Blob`, `File`, `ArrayBuffer`, or `string`.',
46
57
  },
58
+ [StorageValidationErrorCode.InvalidStorageOperationInput]: {
59
+ message: 'Path or key parameter must be specified in the input. Both can not be specified at the same time.',
60
+ },
61
+ [StorageValidationErrorCode.InvalidStorageOperationPrefixInput]: {
62
+ message: 'Both path and prefix can not be specified at the same time.',
63
+ },
64
+ [StorageValidationErrorCode.InvalidStoragePathInput]: {
65
+ message: 'Input `path` does not allow a leading slash (/).',
66
+ },
47
67
  };
48
68
 
49
69
  export { StorageValidationErrorCode, validationErrorMap };