@aws-amplify/storage 5.6.3 → 5.6.4-api-v6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/lib/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
  2. package/lib/AwsClients/S3/abortMultipartUpload.js +85 -0
  3. package/lib/AwsClients/S3/base.d.ts +54 -0
  4. package/lib/AwsClients/S3/base.js +75 -0
  5. package/lib/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
  6. package/lib/AwsClients/S3/completeMultipartUpload.js +162 -0
  7. package/lib/AwsClients/S3/copyObject.d.ts +24 -0
  8. package/lib/AwsClients/S3/copyObject.js +98 -0
  9. package/lib/AwsClients/S3/createMultipartUpload.d.ts +21 -0
  10. package/lib/AwsClients/S3/createMultipartUpload.js +95 -0
  11. package/lib/AwsClients/S3/deleteObject.d.ts +20 -0
  12. package/lib/AwsClients/S3/deleteObject.js +86 -0
  13. package/lib/AwsClients/S3/getObject.d.ts +27 -0
  14. package/lib/AwsClients/S3/getObject.js +216 -0
  15. package/lib/AwsClients/S3/headObject.d.ts +20 -0
  16. package/lib/AwsClients/S3/headObject.js +96 -0
  17. package/lib/AwsClients/S3/index.d.ts +13 -0
  18. package/lib/AwsClients/S3/index.js +30 -0
  19. package/lib/AwsClients/S3/index.native.d.ts +14 -0
  20. package/lib/AwsClients/S3/index.native.js +31 -0
  21. package/lib/AwsClients/S3/listObjectsV2.d.ts +20 -0
  22. package/lib/AwsClients/S3/listObjectsV2.js +146 -0
  23. package/lib/AwsClients/S3/listParts.d.ts +20 -0
  24. package/lib/AwsClients/S3/listParts.js +110 -0
  25. package/lib/AwsClients/S3/putObject.d.ts +23 -0
  26. package/lib/AwsClients/S3/putObject.js +93 -0
  27. package/lib/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
  28. package/lib/AwsClients/S3/runtime/base64/index.browser.js +20 -0
  29. package/lib/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
  30. package/lib/AwsClients/S3/runtime/base64/index.native.js +17 -0
  31. package/lib/AwsClients/S3/runtime/constants.d.ts +9 -0
  32. package/lib/AwsClients/S3/runtime/constants.js +14 -0
  33. package/lib/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
  34. package/lib/AwsClients/S3/runtime/contentSha256middleware.js +70 -0
  35. package/lib/AwsClients/S3/runtime/index.browser.d.ts +5 -0
  36. package/lib/AwsClients/S3/runtime/index.browser.js +20 -0
  37. package/lib/AwsClients/S3/runtime/index.d.ts +5 -0
  38. package/lib/AwsClients/S3/runtime/index.js +21 -0
  39. package/lib/AwsClients/S3/runtime/index.native.d.ts +5 -0
  40. package/lib/AwsClients/S3/runtime/index.native.js +20 -0
  41. package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
  42. package/lib/AwsClients/S3/runtime/s3TransferHandler/fetch.js +15 -0
  43. package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
  44. package/lib/AwsClients/S3/runtime/s3TransferHandler/xhr.js +21 -0
  45. package/lib/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
  46. package/lib/AwsClients/S3/runtime/xhrTransferHandler.js +201 -0
  47. package/lib/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
  48. package/lib/AwsClients/S3/runtime/xmlParser/dom.js +92 -0
  49. package/lib/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
  50. package/lib/AwsClients/S3/runtime/xmlParser/pureJs.js +57 -0
  51. package/lib/AwsClients/S3/types.d.ts +2857 -0
  52. package/lib/AwsClients/S3/types.js +4 -0
  53. package/lib/AwsClients/S3/uploadPart.d.ts +20 -0
  54. package/lib/AwsClients/S3/uploadPart.js +96 -0
  55. package/lib/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
  56. package/lib/AwsClients/S3/utils/deserializeHelpers.js +153 -0
  57. package/lib/AwsClients/S3/utils/index.d.ts +5 -0
  58. package/lib/AwsClients/S3/utils/index.js +30 -0
  59. package/lib/AwsClients/S3/utils/parsePayload.d.ts +3 -0
  60. package/lib/AwsClients/S3/utils/parsePayload.js +96 -0
  61. package/lib/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
  62. package/lib/AwsClients/S3/utils/serializeHelpers.js +183 -0
  63. package/lib/Storage.d.ts +5 -5
  64. package/lib/Storage.js +60 -31
  65. package/lib/common/S3ClientUtils.d.ts +24 -15
  66. package/lib/common/S3ClientUtils.js +83 -95
  67. package/lib/common/StorageConstants.d.ts +0 -1
  68. package/lib/common/StorageConstants.js +3 -2
  69. package/lib/common/StorageErrorStrings.js +3 -1
  70. package/lib/common/StorageUtils.js +12 -6
  71. package/lib/index.js +19 -4
  72. package/lib/providers/AWSS3Provider.d.ts +4 -8
  73. package/lib/providers/AWSS3Provider.js +210 -139
  74. package/lib/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
  75. package/lib/providers/AWSS3ProviderManagedUpload.js +184 -98
  76. package/lib/providers/AWSS3UploadTask.d.ts +8 -8
  77. package/lib/providers/AWSS3UploadTask.js +226 -129
  78. package/lib/providers/index.js +4 -2
  79. package/lib/tsconfig.tsbuildinfo +1 -0
  80. package/lib/types/AWSS3Provider.d.ts +62 -62
  81. package/lib/types/AWSS3Provider.js +0 -1
  82. package/lib/types/Provider.d.ts +1 -1
  83. package/lib/types/Provider.js +2 -1
  84. package/lib/types/Storage.d.ts +23 -23
  85. package/lib/types/Storage.js +0 -1
  86. package/lib/types/index.js +17 -1
  87. package/lib-esm/AwsClients/S3/abortMultipartUpload.d.ts +21 -0
  88. package/lib-esm/AwsClients/S3/abortMultipartUpload.js +82 -0
  89. package/lib-esm/AwsClients/S3/base.d.ts +54 -0
  90. package/lib-esm/AwsClients/S3/base.js +71 -0
  91. package/lib-esm/AwsClients/S3/completeMultipartUpload.d.ts +20 -0
  92. package/lib-esm/AwsClients/S3/completeMultipartUpload.js +159 -0
  93. package/lib-esm/AwsClients/S3/copyObject.d.ts +24 -0
  94. package/lib-esm/AwsClients/S3/copyObject.js +95 -0
  95. package/lib-esm/AwsClients/S3/createMultipartUpload.d.ts +21 -0
  96. package/lib-esm/AwsClients/S3/createMultipartUpload.js +92 -0
  97. package/lib-esm/AwsClients/S3/deleteObject.d.ts +20 -0
  98. package/lib-esm/AwsClients/S3/deleteObject.js +83 -0
  99. package/lib-esm/AwsClients/S3/getObject.d.ts +27 -0
  100. package/lib-esm/AwsClients/S3/getObject.js +212 -0
  101. package/lib-esm/AwsClients/S3/headObject.d.ts +20 -0
  102. package/lib-esm/AwsClients/S3/headObject.js +93 -0
  103. package/lib-esm/AwsClients/S3/index.d.ts +13 -0
  104. package/lib-esm/AwsClients/S3/index.js +14 -0
  105. package/lib-esm/AwsClients/S3/index.native.d.ts +14 -0
  106. package/lib-esm/AwsClients/S3/index.native.js +15 -0
  107. package/lib-esm/AwsClients/S3/listObjectsV2.d.ts +20 -0
  108. package/lib-esm/AwsClients/S3/listObjectsV2.js +143 -0
  109. package/lib-esm/AwsClients/S3/listParts.d.ts +20 -0
  110. package/lib-esm/AwsClients/S3/listParts.js +107 -0
  111. package/lib-esm/AwsClients/S3/putObject.d.ts +23 -0
  112. package/lib-esm/AwsClients/S3/putObject.js +90 -0
  113. package/lib-esm/AwsClients/S3/runtime/base64/index.browser.d.ts +2 -0
  114. package/lib-esm/AwsClients/S3/runtime/base64/index.browser.js +15 -0
  115. package/lib-esm/AwsClients/S3/runtime/base64/index.native.d.ts +2 -0
  116. package/lib-esm/AwsClients/S3/runtime/base64/index.native.js +12 -0
  117. package/lib-esm/AwsClients/S3/runtime/constants.d.ts +9 -0
  118. package/lib-esm/AwsClients/S3/runtime/constants.js +11 -0
  119. package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.d.ts +9 -0
  120. package/lib-esm/AwsClients/S3/runtime/contentSha256middleware.js +66 -0
  121. package/lib-esm/AwsClients/S3/runtime/index.browser.d.ts +5 -0
  122. package/lib-esm/AwsClients/S3/runtime/index.browser.js +8 -0
  123. package/lib-esm/AwsClients/S3/runtime/index.d.ts +5 -0
  124. package/lib-esm/AwsClients/S3/runtime/index.js +9 -0
  125. package/lib-esm/AwsClients/S3/runtime/index.native.d.ts +5 -0
  126. package/lib-esm/AwsClients/S3/runtime/index.native.js +8 -0
  127. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.d.ts +8 -0
  128. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/fetch.js +12 -0
  129. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.d.ts +8 -0
  130. package/lib-esm/AwsClients/S3/runtime/s3TransferHandler/xhr.js +18 -0
  131. package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.d.ts +22 -0
  132. package/lib-esm/AwsClients/S3/runtime/xhrTransferHandler.js +196 -0
  133. package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.d.ts +8 -0
  134. package/lib-esm/AwsClients/S3/runtime/xmlParser/dom.js +89 -0
  135. package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.d.ts +10 -0
  136. package/lib-esm/AwsClients/S3/runtime/xmlParser/pureJs.js +54 -0
  137. package/lib-esm/AwsClients/S3/types.d.ts +2857 -0
  138. package/lib-esm/AwsClients/S3/types.js +3 -0
  139. package/lib-esm/AwsClients/S3/uploadPart.d.ts +20 -0
  140. package/lib-esm/AwsClients/S3/uploadPart.js +93 -0
  141. package/lib-esm/AwsClients/S3/utils/deserializeHelpers.d.ts +78 -0
  142. package/lib-esm/AwsClients/S3/utils/deserializeHelpers.js +144 -0
  143. package/lib-esm/AwsClients/S3/utils/index.d.ts +5 -0
  144. package/lib-esm/AwsClients/S3/utils/index.js +7 -0
  145. package/lib-esm/AwsClients/S3/utils/parsePayload.d.ts +3 -0
  146. package/lib-esm/AwsClients/S3/utils/parsePayload.js +91 -0
  147. package/lib-esm/AwsClients/S3/utils/serializeHelpers.d.ts +42 -0
  148. package/lib-esm/AwsClients/S3/utils/serializeHelpers.js +176 -0
  149. package/lib-esm/Storage.d.ts +5 -5
  150. package/lib-esm/Storage.js +53 -25
  151. package/lib-esm/common/S3ClientUtils.d.ts +24 -15
  152. package/lib-esm/common/S3ClientUtils.js +76 -93
  153. package/lib-esm/common/StorageConstants.d.ts +0 -1
  154. package/lib-esm/common/StorageConstants.js +2 -2
  155. package/lib-esm/common/StorageErrorStrings.js +2 -1
  156. package/lib-esm/common/StorageUtils.js +2 -1
  157. package/lib-esm/index.js +1 -1
  158. package/lib-esm/providers/AWSS3Provider.d.ts +4 -8
  159. package/lib-esm/providers/AWSS3Provider.js +162 -115
  160. package/lib-esm/providers/AWSS3ProviderManagedUpload.d.ts +7 -7
  161. package/lib-esm/providers/AWSS3ProviderManagedUpload.js +172 -87
  162. package/lib-esm/providers/AWSS3UploadTask.d.ts +8 -8
  163. package/lib-esm/providers/AWSS3UploadTask.js +202 -106
  164. package/lib-esm/providers/index.js +2 -1
  165. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  166. package/lib-esm/types/AWSS3Provider.d.ts +62 -62
  167. package/lib-esm/types/AWSS3Provider.js +1 -1
  168. package/lib-esm/types/Provider.d.ts +1 -1
  169. package/lib-esm/types/Provider.js +3 -1
  170. package/lib-esm/types/Storage.d.ts +23 -23
  171. package/lib-esm/types/Storage.js +1 -1
  172. package/lib-esm/types/index.js +3 -1
  173. package/package.json +21 -26
  174. package/src/AwsClients/S3/abortMultipartUpload.ts +62 -0
  175. package/src/AwsClients/S3/base.ts +109 -0
  176. package/src/AwsClients/S3/completeMultipartUpload.ts +154 -0
  177. package/src/AwsClients/S3/copyObject.ts +90 -0
  178. package/src/AwsClients/S3/createMultipartUpload.ts +75 -0
  179. package/src/AwsClients/S3/deleteObject.ts +69 -0
  180. package/src/AwsClients/S3/getObject.ts +173 -0
  181. package/src/AwsClients/S3/headObject.ts +91 -0
  182. package/src/AwsClients/S3/index.native.ts +42 -0
  183. package/src/AwsClients/S3/index.ts +41 -0
  184. package/src/AwsClients/S3/listObjectsV2.ts +130 -0
  185. package/src/AwsClients/S3/listParts.ts +97 -0
  186. package/src/AwsClients/S3/putObject.ts +94 -0
  187. package/src/AwsClients/S3/runtime/base64/index.browser.ts +21 -0
  188. package/src/AwsClients/S3/runtime/base64/index.native.ts +16 -0
  189. package/src/AwsClients/S3/runtime/constants.ts +16 -0
  190. package/src/AwsClients/S3/runtime/contentSha256middleware.ts +29 -0
  191. package/src/AwsClients/S3/runtime/index.browser.ts +14 -0
  192. package/src/AwsClients/S3/runtime/index.native.ts +14 -0
  193. package/src/AwsClients/S3/runtime/index.ts +15 -0
  194. package/src/AwsClients/S3/runtime/s3TransferHandler/fetch.ts +23 -0
  195. package/src/AwsClients/S3/runtime/s3TransferHandler/xhr.ts +35 -0
  196. package/src/AwsClients/S3/runtime/xhrTransferHandler.ts +254 -0
  197. package/src/AwsClients/S3/runtime/xmlParser/dom.ts +92 -0
  198. package/src/AwsClients/S3/runtime/xmlParser/pureJs.ts +55 -0
  199. package/src/AwsClients/S3/types.ts +2877 -0
  200. package/src/AwsClients/S3/uploadPart.ts +83 -0
  201. package/src/AwsClients/S3/utils/deserializeHelpers.ts +136 -0
  202. package/src/AwsClients/S3/utils/index.ts +27 -0
  203. package/src/AwsClients/S3/utils/parsePayload.ts +45 -0
  204. package/src/AwsClients/S3/utils/serializeHelpers.ts +112 -0
  205. package/src/Storage.ts +30 -27
  206. package/src/common/S3ClientUtils.ts +57 -113
  207. package/src/common/StorageConstants.ts +2 -2
  208. package/src/common/StorageErrorStrings.ts +2 -0
  209. package/src/common/StorageUtils.ts +2 -0
  210. package/src/providers/AWSS3Provider.ts +80 -100
  211. package/src/providers/AWSS3ProviderManagedUpload.ts +56 -63
  212. package/src/providers/AWSS3UploadTask.ts +86 -87
  213. package/src/providers/index.ts +2 -0
  214. package/src/types/AWSS3Provider.ts +55 -49
  215. package/src/types/Provider.ts +7 -2
  216. package/lib/.tsbuildinfo +0 -3
  217. package/lib/Storage.js.map +0 -1
  218. package/lib/common/S3ClientUtils.js.map +0 -1
  219. package/lib/common/StorageConstants.js.map +0 -1
  220. package/lib/common/StorageErrorStrings.js.map +0 -1
  221. package/lib/common/StorageUtils.js.map +0 -1
  222. package/lib/index.js.map +0 -1
  223. package/lib/providers/AWSS3Provider.js.map +0 -1
  224. package/lib/providers/AWSS3ProviderManagedUpload.js.map +0 -1
  225. package/lib/providers/AWSS3UploadTask.js.map +0 -1
  226. package/lib/providers/axios-http-handler.d.ts +0 -40
  227. package/lib/providers/axios-http-handler.js +0 -193
  228. package/lib/providers/axios-http-handler.js.map +0 -1
  229. package/lib/providers/index.js.map +0 -1
  230. package/lib/types/AWSS3Provider.js.map +0 -1
  231. package/lib/types/Provider.js.map +0 -1
  232. package/lib/types/Storage.js.map +0 -1
  233. package/lib/types/index.js.map +0 -1
  234. package/lib-esm/.tsbuildinfo +0 -3
  235. package/lib-esm/Storage.js.map +0 -1
  236. package/lib-esm/common/S3ClientUtils.js.map +0 -1
  237. package/lib-esm/common/StorageConstants.js.map +0 -1
  238. package/lib-esm/common/StorageErrorStrings.js.map +0 -1
  239. package/lib-esm/common/StorageUtils.js.map +0 -1
  240. package/lib-esm/index.js.map +0 -1
  241. package/lib-esm/providers/AWSS3Provider.js.map +0 -1
  242. package/lib-esm/providers/AWSS3ProviderManagedUpload.js.map +0 -1
  243. package/lib-esm/providers/AWSS3UploadTask.js.map +0 -1
  244. package/lib-esm/providers/axios-http-handler.d.ts +0 -40
  245. package/lib-esm/providers/axios-http-handler.js +0 -191
  246. package/lib-esm/providers/axios-http-handler.js.map +0 -1
  247. package/lib-esm/providers/index.js.map +0 -1
  248. package/lib-esm/types/AWSS3Provider.js.map +0 -1
  249. package/lib-esm/types/Provider.js.map +0 -1
  250. package/lib-esm/types/Storage.js.map +0 -1
  251. package/lib-esm/types/index.js.map +0 -1
  252. package/src/providers/axios-http-handler.ts +0 -242
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
- import { PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
3
- import * as events from 'events';
2
+ import { PutObjectInput } from '../AwsClients/S3';
3
+ import { EventEmitter } from 'events';
4
4
  export declare interface Part {
5
5
  bodyPart: any;
6
6
  partNumber: number;
7
- emitter: events.EventEmitter;
7
+ emitter: EventEmitter;
8
8
  etag?: string;
9
9
  _lastUploadedBytes: number;
10
10
  }
@@ -13,14 +13,14 @@ export declare class AWSS3ProviderManagedUpload {
13
13
  private params;
14
14
  private opts;
15
15
  private completedParts;
16
- private s3client;
16
+ private s3Config;
17
17
  private uploadId;
18
18
  private partSize;
19
19
  private bytesUploaded;
20
20
  private totalBytesToUpload;
21
21
  private emitter;
22
- constructor(params: PutObjectCommandInput, opts: any, emitter: events.EventEmitter);
23
- upload(): Promise<string | import("@aws-sdk/client-s3/types/").PutObjectCommandOutput>;
22
+ constructor(params: PutObjectInput, opts: any, emitter: EventEmitter);
23
+ upload(): Promise<string | import("../AwsClients/S3").PutObjectOutput>;
24
24
  private createParts;
25
25
  private createMultiPartUpload;
26
26
  /**
@@ -36,5 +36,5 @@ export declare class AWSS3ProviderManagedUpload {
36
36
  private byteLength;
37
37
  private validateAndSanitizeBody;
38
38
  private isGenericObject;
39
- protected _createNewS3Client(config: any, emitter?: events.EventEmitter): S3Client;
39
+ private getObjectKeyWithPrefix;
40
40
  }
@@ -1,12 +1,59 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
+ var __assign = (this && this.__assign) || function () {
5
+ __assign = Object.assign || function(t) {
6
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7
+ s = arguments[i];
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
9
+ t[p] = s[p];
10
+ }
11
+ return t;
12
+ };
13
+ return __assign.apply(this, arguments);
14
+ };
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ var __generator = (this && this.__generator) || function (thisArg, body) {
25
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ function verb(n) { return function (v) { return step([n, v]); }; }
28
+ function step(op) {
29
+ if (f) throw new TypeError("Generator is already executing.");
30
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
+ if (y = 0, t) op = [op[0] & 2, t.value];
33
+ switch (op[0]) {
34
+ case 0: case 1: t = op; break;
35
+ case 4: _.label++; return { value: op[1], done: false };
36
+ case 5: _.label++; y = op[1]; op = [0]; continue;
37
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
+ default:
39
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
+ if (t[2]) _.ops.pop();
44
+ _.trys.pop(); continue;
45
+ }
46
+ op = body.call(thisArg, _);
47
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
+ }
50
+ };
4
51
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
52
+ exports.AWSS3ProviderManagedUpload = void 0;
6
53
  var core_1 = require("@aws-amplify/core");
7
- var client_s3_1 = require("@aws-sdk/client-s3");
8
- var axios_http_handler_1 = require("./axios-http-handler");
9
- var events = tslib_1.__importStar(require("events"));
54
+ var S3_1 = require("../AwsClients/S3");
55
+ var utils_1 = require("../AwsClients/S3/utils");
56
+ var events_1 = require("events");
10
57
  var S3ClientUtils_1 = require("../common/S3ClientUtils");
11
58
  var logger = new core_1.ConsoleLogger('AWSS3ProviderManagedUpload');
12
59
  var AWSS3ProviderManagedUpload = /** @class */ (function () {
@@ -21,66 +68,71 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
21
68
  this.params = params;
22
69
  this.opts = opts;
23
70
  this.emitter = emitter;
24
- this.s3client = this._createNewS3Client(opts, emitter);
71
+ this.s3Config = (0, S3ClientUtils_1.loadS3Config)(__assign(__assign({}, opts), { emitter: emitter, storageAction: core_1.StorageAction.Put }));
25
72
  }
26
73
  AWSS3ProviderManagedUpload.prototype.upload = function () {
27
- return tslib_1.__awaiter(this, void 0, void 0, function () {
28
- var putObjectCommand, _a, numberOfPartsToUpload, parts, start, error_1;
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var _a, _b, _c, _d, numberOfPartsToUpload, parts, start, error_1;
76
+ var _e;
29
77
  var _this = this;
30
- return tslib_1.__generator(this, function (_b) {
31
- switch (_b.label) {
78
+ return __generator(this, function (_f) {
79
+ switch (_f.label) {
32
80
  case 0:
33
- _b.trys.push([0, 9, , 11]);
81
+ _f.trys.push([0, 10, , 12]);
34
82
  this.body = this.validateAndSanitizeBody(this.params.Body);
35
83
  this.totalBytesToUpload = this.byteLength(this.body);
36
- if (!(this.totalBytesToUpload <= S3ClientUtils_1.DEFAULT_PART_SIZE)) return [3 /*break*/, 1];
84
+ if (!(this.totalBytesToUpload <= S3ClientUtils_1.DEFAULT_PART_SIZE)) return [3 /*break*/, 2];
37
85
  // Multipart upload is not required. Upload the sanitized body as is
38
86
  this.params.Body = this.body;
39
- putObjectCommand = new client_s3_1.PutObjectCommand(this.params);
40
- return [2 /*return*/, this.s3client.send(putObjectCommand)];
41
- case 1:
87
+ _a = S3_1.putObject;
88
+ _b = [this.s3Config];
89
+ _c = [__assign({}, this.params)];
90
+ _e = {};
91
+ return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
92
+ case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_e.Key = _f.sent(), _e)]))]))];
93
+ case 2:
42
94
  // Step 1: Determine appropriate part size.
43
- this.partSize = S3ClientUtils_1.calculatePartSize(this.totalBytesToUpload);
95
+ this.partSize = (0, S3ClientUtils_1.calculatePartSize)(this.totalBytesToUpload);
44
96
  // Step 2: Initiate the multi part upload
45
- _a = this;
97
+ _d = this;
46
98
  return [4 /*yield*/, this.createMultiPartUpload()];
47
- case 2:
99
+ case 3:
48
100
  // Step 2: Initiate the multi part upload
49
- _a.uploadId = _b.sent();
101
+ _d.uploadId = _f.sent();
50
102
  numberOfPartsToUpload = Math.ceil(this.totalBytesToUpload / this.partSize);
51
103
  parts = this.createParts();
52
104
  start = 0;
53
- _b.label = 3;
54
- case 3:
55
- if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 6];
56
- // Upload as many as `queueSize` parts simultaneously
57
- return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + S3ClientUtils_1.DEFAULT_QUEUE_SIZE))];
105
+ _f.label = 4;
58
106
  case 4:
107
+ if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 7];
59
108
  // Upload as many as `queueSize` parts simultaneously
60
- _b.sent();
61
- _b.label = 5;
109
+ return [4 /*yield*/, this.uploadParts(this.uploadId, parts.slice(start, start + S3ClientUtils_1.DEFAULT_QUEUE_SIZE))];
62
110
  case 5:
63
- start += S3ClientUtils_1.DEFAULT_QUEUE_SIZE;
64
- return [3 /*break*/, 3];
111
+ // Upload as many as `queueSize` parts simultaneously
112
+ _f.sent();
113
+ _f.label = 6;
65
114
  case 6:
115
+ start += S3ClientUtils_1.DEFAULT_QUEUE_SIZE;
116
+ return [3 /*break*/, 4];
117
+ case 7:
66
118
  parts.map(function (part) {
67
119
  _this.removeEventListener(part);
68
120
  });
69
121
  return [4 /*yield*/, this.finishMultiPartUpload(this.uploadId)];
70
- case 7:
122
+ case 8:
71
123
  // Step 3: Finalize the upload such that S3 can recreate the file
72
- return [2 /*return*/, _b.sent()];
73
- case 8: return [3 /*break*/, 11];
74
- case 9:
75
- error_1 = _b.sent();
124
+ return [2 /*return*/, _f.sent()];
125
+ case 9: return [3 /*break*/, 12];
126
+ case 10:
127
+ error_1 = _f.sent();
76
128
  // if any error is thrown, call cleanup
77
129
  return [4 /*yield*/, this.cleanup(this.uploadId)];
78
- case 10:
130
+ case 11:
79
131
  // if any error is thrown, call cleanup
80
- _b.sent();
132
+ _f.sent();
81
133
  logger.error('Error. Cancelling the multipart upload.');
82
134
  throw error_1;
83
- case 11: return [2 /*return*/];
135
+ case 12: return [2 /*return*/];
84
136
  }
85
137
  });
86
138
  });
@@ -93,7 +145,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
93
145
  parts.push({
94
146
  bodyPart: this.body.slice(bodyStart, bodyEnd),
95
147
  partNumber: parts.length + 1,
96
- emitter: new events.EventEmitter(),
148
+ emitter: new events_1.EventEmitter(),
97
149
  _lastUploadedBytes: 0,
98
150
  });
99
151
  bodyStart += this.partSize;
@@ -106,23 +158,28 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
106
158
  }
107
159
  };
108
160
  AWSS3ProviderManagedUpload.prototype.createMultiPartUpload = function () {
109
- return tslib_1.__awaiter(this, void 0, void 0, function () {
110
- var createMultiPartUploadCommand, response, error_2;
111
- return tslib_1.__generator(this, function (_a) {
112
- switch (_a.label) {
161
+ return __awaiter(this, void 0, void 0, function () {
162
+ var response, _a, _b, _c, error_2;
163
+ var _d;
164
+ return __generator(this, function (_e) {
165
+ switch (_e.label) {
113
166
  case 0:
114
- _a.trys.push([0, 2, , 3]);
115
- createMultiPartUploadCommand = new client_s3_1.CreateMultipartUploadCommand(this.params);
116
- return [4 /*yield*/, this.s3client.send(createMultiPartUploadCommand)];
117
- case 1:
118
- response = _a.sent();
167
+ _e.trys.push([0, 3, , 4]);
168
+ _a = S3_1.createMultipartUpload;
169
+ _b = [this.s3Config];
170
+ _c = [__assign({}, this.params)];
171
+ _d = {};
172
+ return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
173
+ case 1: return [4 /*yield*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_d.Key = _e.sent(), _d)]))]))];
174
+ case 2:
175
+ response = _e.sent();
119
176
  logger.debug(response.UploadId);
120
177
  return [2 /*return*/, response.UploadId];
121
- case 2:
122
- error_2 = _a.sent();
178
+ case 3:
179
+ error_2 = _e.sent();
123
180
  logger.error(error_2);
124
181
  throw error_2;
125
- case 3: return [2 /*return*/];
182
+ case 4: return [2 /*return*/];
126
183
  }
127
184
  });
128
185
  });
@@ -132,25 +189,37 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
132
189
  * @VisibleFotTesting
133
190
  */
134
191
  AWSS3ProviderManagedUpload.prototype.uploadParts = function (uploadId, parts) {
135
- return tslib_1.__awaiter(this, void 0, void 0, function () {
192
+ return __awaiter(this, void 0, void 0, function () {
136
193
  var allResults, i, error_3;
137
194
  var _this = this;
138
- return tslib_1.__generator(this, function (_a) {
195
+ return __generator(this, function (_a) {
139
196
  switch (_a.label) {
140
197
  case 0:
141
198
  _a.trys.push([0, 2, , 3]);
142
- return [4 /*yield*/, Promise.all(parts.map(function (part) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
143
- var options, _a, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, res;
144
- return tslib_1.__generator(this, function (_b) {
145
- switch (_b.label) {
199
+ return [4 /*yield*/, Promise.all(parts.map(function (part) { return __awaiter(_this, void 0, void 0, function () {
200
+ var _a, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, res, _b, _c;
201
+ var _d;
202
+ return __generator(this, function (_e) {
203
+ switch (_e.label) {
146
204
  case 0:
147
205
  this.setupEventListener(part);
148
- options = { emitter: part.emitter };
149
206
  _a = this.params, Key = _a.Key, Bucket = _a.Bucket, SSECustomerAlgorithm = _a.SSECustomerAlgorithm, SSECustomerKey = _a.SSECustomerKey, SSECustomerKeyMD5 = _a.SSECustomerKeyMD5;
150
- return [4 /*yield*/, this.s3client.send(new client_s3_1.UploadPartCommand(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ PartNumber: part.partNumber, Body: part.bodyPart, UploadId: uploadId, Key: Key,
151
- Bucket: Bucket }, (SSECustomerAlgorithm && { SSECustomerAlgorithm: SSECustomerAlgorithm })), (SSECustomerKey && { SSECustomerKey: SSECustomerKey })), (SSECustomerKeyMD5 && { SSECustomerKeyMD5: SSECustomerKeyMD5 }))), options)];
152
- case 1:
153
- res = _b.sent();
207
+ _b = S3_1.uploadPart;
208
+ _c = [__assign(__assign({}, this.s3Config), { emitter: part.emitter })];
209
+ _d = {
210
+ PartNumber: part.partNumber,
211
+ Body: part.bodyPart,
212
+ UploadId: uploadId
213
+ };
214
+ return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
215
+ case 1: return [4 /*yield*/, _b.apply(void 0, _c.concat([(_d.Key = _e.sent(),
216
+ _d.Bucket = Bucket,
217
+ _d.SSECustomerAlgorithm = SSECustomerAlgorithm,
218
+ _d.SSECustomerKey = SSECustomerKey,
219
+ _d.SSECustomerKeyMD5 = SSECustomerKeyMD5,
220
+ _d)]))];
221
+ case 2:
222
+ res = _e.sent();
154
223
  return [2 /*return*/, res];
155
224
  }
156
225
  });
@@ -175,39 +244,43 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
175
244
  });
176
245
  };
177
246
  AWSS3ProviderManagedUpload.prototype.finishMultiPartUpload = function (uploadId) {
178
- return tslib_1.__awaiter(this, void 0, void 0, function () {
179
- var input, completeUploadCommand, data, error_4;
180
- return tslib_1.__generator(this, function (_a) {
181
- switch (_a.label) {
247
+ return __awaiter(this, void 0, void 0, function () {
248
+ var input, Key, error_4;
249
+ var _a;
250
+ return __generator(this, function (_b) {
251
+ switch (_b.label) {
182
252
  case 0:
183
- input = {
184
- Bucket: this.params.Bucket,
185
- Key: this.params.Key,
186
- UploadId: uploadId,
187
- MultipartUpload: { Parts: this.completedParts },
253
+ _a = {
254
+ Bucket: this.params.Bucket
188
255
  };
189
- completeUploadCommand = new client_s3_1.CompleteMultipartUploadCommand(input);
190
- _a.label = 1;
256
+ return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
191
257
  case 1:
192
- _a.trys.push([1, 3, , 4]);
193
- return [4 /*yield*/, this.s3client.send(completeUploadCommand)];
258
+ input = (_a.Key = _b.sent(),
259
+ _a.UploadId = uploadId,
260
+ _a.MultipartUpload = { Parts: this.completedParts },
261
+ _a);
262
+ _b.label = 2;
194
263
  case 2:
195
- data = _a.sent();
196
- return [2 /*return*/, data.Key];
264
+ _b.trys.push([2, 4, , 5]);
265
+ return [4 /*yield*/, (0, S3_1.completeMultipartUpload)(this.s3Config, input)];
197
266
  case 3:
198
- error_4 = _a.sent();
267
+ Key = (_b.sent()).Key;
268
+ return [2 /*return*/, Key];
269
+ case 4:
270
+ error_4 = _b.sent();
199
271
  logger.error('Error happened while finishing the upload.');
200
272
  throw error_4;
201
- case 4: return [2 /*return*/];
273
+ case 5: return [2 /*return*/];
202
274
  }
203
275
  });
204
276
  });
205
277
  };
206
278
  AWSS3ProviderManagedUpload.prototype.cleanup = function (uploadId) {
207
- return tslib_1.__awaiter(this, void 0, void 0, function () {
279
+ return __awaiter(this, void 0, void 0, function () {
208
280
  var input, data;
209
- return tslib_1.__generator(this, function (_a) {
210
- switch (_a.label) {
281
+ var _a;
282
+ return __generator(this, function (_b) {
283
+ switch (_b.label) {
211
284
  case 0:
212
285
  // Reset this's state
213
286
  this.body = null;
@@ -218,17 +291,20 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
218
291
  // This is a single part upload;
219
292
  return [2 /*return*/];
220
293
  }
221
- input = {
222
- Bucket: this.params.Bucket,
223
- Key: this.params.Key,
224
- UploadId: uploadId,
294
+ _a = {
295
+ Bucket: this.params.Bucket
225
296
  };
226
- return [4 /*yield*/, this.s3client.send(new client_s3_1.AbortMultipartUploadCommand(input))];
297
+ return [4 /*yield*/, this.getObjectKeyWithPrefix(this.params.Key)];
227
298
  case 1:
228
- _a.sent();
229
- return [4 /*yield*/, this.s3client.send(new client_s3_1.ListPartsCommand(input))];
299
+ input = (_a.Key = _b.sent(),
300
+ _a.UploadId = uploadId,
301
+ _a);
302
+ return [4 /*yield*/, (0, S3_1.abortMultipartUpload)(this.s3Config, input)];
230
303
  case 2:
231
- data = _a.sent();
304
+ _b.sent();
305
+ return [4 /*yield*/, (0, S3_1.listParts)(this.s3Config, input)];
306
+ case 3:
307
+ data = _b.sent();
232
308
  if (data && data.Parts && data.Parts.length > 0) {
233
309
  throw new Error('Multipart upload clean up failed.');
234
310
  }
@@ -238,19 +314,19 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
238
314
  });
239
315
  };
240
316
  AWSS3ProviderManagedUpload.prototype.removeEventListener = function (part) {
241
- part.emitter.removeAllListeners(axios_http_handler_1.SEND_UPLOAD_PROGRESS_EVENT);
242
- part.emitter.removeAllListeners(axios_http_handler_1.SEND_DOWNLOAD_PROGRESS_EVENT);
317
+ part.emitter.removeAllListeners(utils_1.SEND_UPLOAD_PROGRESS_EVENT);
318
+ part.emitter.removeAllListeners(utils_1.SEND_DOWNLOAD_PROGRESS_EVENT);
243
319
  };
244
320
  AWSS3ProviderManagedUpload.prototype.setupEventListener = function (part) {
245
321
  var _this = this;
246
- part.emitter.on(axios_http_handler_1.SEND_UPLOAD_PROGRESS_EVENT, function (progress) {
322
+ part.emitter.on(utils_1.SEND_UPLOAD_PROGRESS_EVENT, function (progress) {
247
323
  _this.progressChanged(part.partNumber, progress.loaded - part._lastUploadedBytes);
248
324
  part._lastUploadedBytes = progress.loaded;
249
325
  });
250
326
  };
251
327
  AWSS3ProviderManagedUpload.prototype.progressChanged = function (partNumber, incrementalUpdate) {
252
328
  this.bytesUploaded += incrementalUpdate;
253
- this.emitter.emit(axios_http_handler_1.SEND_UPLOAD_PROGRESS_EVENT, {
329
+ this.emitter.emit(utils_1.SEND_UPLOAD_PROGRESS_EVENT, {
254
330
  loaded: this.bytesUploaded,
255
331
  total: this.totalBytesToUpload,
256
332
  part: partNumber,
@@ -290,7 +366,7 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
290
366
  sanitizedBody = body;
291
367
  } */
292
368
  if (this.byteLength(sanitizedBody) > S3ClientUtils_1.MAX_OBJECT_SIZE) {
293
- throw new Error("File size bigger than S3 Object limit of 5TB, got " + this.totalBytesToUpload + " Bytes");
369
+ throw new Error("File size bigger than S3 Object limit of 5TB, got ".concat(this.totalBytesToUpload, " Bytes"));
294
370
  }
295
371
  return sanitizedBody;
296
372
  };
@@ -307,13 +383,23 @@ var AWSS3ProviderManagedUpload = /** @class */ (function () {
307
383
  }
308
384
  return false;
309
385
  };
310
- AWSS3ProviderManagedUpload.prototype._createNewS3Client = function (config, emitter) {
311
- var s3client = S3ClientUtils_1.createS3Client(config, core_1.StorageAction.Put, emitter);
312
- s3client.middlewareStack.add(S3ClientUtils_1.createPrefixMiddleware(this.opts, this.params.Key), S3ClientUtils_1.prefixMiddlewareOptions);
313
- s3client.middlewareStack.add(S3ClientUtils_1.autoAdjustClockskewMiddleware(s3client.config), S3ClientUtils_1.autoAdjustClockskewMiddlewareOptions);
314
- return s3client;
386
+ AWSS3ProviderManagedUpload.prototype.getObjectKeyWithPrefix = function (keyWithoutPrefix) {
387
+ return __awaiter(this, void 0, void 0, function () {
388
+ var _a, _b;
389
+ var _c;
390
+ return __generator(this, function (_d) {
391
+ switch (_d.label) {
392
+ case 0:
393
+ _a = S3ClientUtils_1.getPrefix;
394
+ _b = [__assign({}, this.opts)];
395
+ _c = {};
396
+ return [4 /*yield*/, (0, S3ClientUtils_1.credentialsProvider)()];
397
+ case 1: return [4 /*yield*/, _a.apply(void 0, [__assign.apply(void 0, _b.concat([(_c.credentials = _d.sent(), _c)]))])];
398
+ case 2: return [2 /*return*/, ((_d.sent()) + keyWithoutPrefix)];
399
+ }
400
+ });
401
+ });
315
402
  };
316
403
  return AWSS3ProviderManagedUpload;
317
404
  }());
318
405
  exports.AWSS3ProviderManagedUpload = AWSS3ProviderManagedUpload;
319
- //# sourceMappingURL=AWSS3ProviderManagedUpload.js.map
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
- import { UploadPartCommandInput, S3Client, PutObjectCommandInput } from '@aws-sdk/client-s3';
3
2
  import * as events from 'events';
4
- import { Canceler } from 'axios';
5
3
  import { UploadTask } from '../types/Provider';
4
+ import { PutObjectInput, UploadPartInput } from '../AwsClients/S3';
5
+ import { S3ResolvedConfig } from '../common/S3ClientUtils';
6
6
  import { StorageAccessLevel } from '..';
7
7
  export declare enum AWSS3UploadTaskState {
8
8
  INIT = 0,
@@ -18,18 +18,18 @@ export declare enum TaskEvents {
18
18
  ERROR = "error"
19
19
  }
20
20
  export interface AWSS3UploadTaskParams {
21
- s3Client: S3Client;
21
+ s3Config: S3ResolvedConfig;
22
22
  file: Blob;
23
23
  storage: Storage;
24
24
  level: StorageAccessLevel;
25
- params: PutObjectCommandInput;
25
+ params: PutObjectInput;
26
26
  prefixPromise: Promise<string>;
27
27
  emitter?: events.EventEmitter;
28
28
  }
29
29
  export interface InProgressRequest {
30
- uploadPartInput: UploadPartCommandInput;
30
+ uploadPartInput: UploadPartInput;
31
31
  s3Request: Promise<any>;
32
- cancel: Canceler;
32
+ abortController: AbortController;
33
33
  }
34
34
  export interface UploadTaskCompleteEvent {
35
35
  key?: string;
@@ -55,7 +55,7 @@ export declare class AWSS3UploadTask implements UploadTask {
55
55
  private readonly emitter;
56
56
  private readonly file;
57
57
  private readonly queueSize;
58
- private readonly s3client;
58
+ private readonly s3Config;
59
59
  private readonly storage;
60
60
  private readonly storageSync;
61
61
  private readonly fileId;
@@ -69,7 +69,7 @@ export declare class AWSS3UploadTask implements UploadTask {
69
69
  private totalBytes;
70
70
  private uploadId;
71
71
  state: AWSS3UploadTaskState;
72
- constructor({ s3Client, file, emitter, storage, params, level, prefixPromise, }: AWSS3UploadTaskParams);
72
+ constructor({ s3Config, file, emitter, storage, params, level, prefixPromise, }: AWSS3UploadTaskParams);
73
73
  get percent(): number;
74
74
  get isInProgress(): boolean;
75
75
  private _listSingleFile;