@aws-amplify/storage 6.6.3 → 6.6.4-server-upload.2bbdb67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/providers/s3/apis/internal/uploadData/byteLength.js.map +1 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData/index.js +156 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData/index.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/calculatePartSize.js +1 -1
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/calculatePartSize.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/getDataChunker.js +2 -2
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/getDataChunker.js.map +1 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/index.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/initialUpload.js +3 -3
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/initialUpload.js.map +1 -0
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/progressTracker.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadCache.js +3 -3
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/uploadCache.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadHandlers.js +12 -13
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadPartExecutor.js +3 -3
- package/dist/cjs/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.js.map +1 -0
- package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/putObjectJob.js +7 -8
- package/dist/cjs/providers/s3/apis/internal/uploadData/putObjectJob.js.map +1 -0
- package/dist/cjs/providers/s3/apis/server/index.js +3 -1
- package/dist/cjs/providers/s3/apis/server/index.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/uploadData.js +13 -0
- package/dist/cjs/providers/s3/apis/server/uploadData.js.map +1 -0
- package/dist/cjs/providers/s3/apis/uploadData.js +13 -0
- package/dist/cjs/providers/s3/apis/uploadData.js.map +1 -0
- package/dist/cjs/providers/s3/utils/client/getObject.js +1 -1
- package/dist/cjs/providers/s3/utils/client/getObject.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/providers/s3/apis/index.mjs +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/byteLength.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/index.d.ts +4 -4
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs +161 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/calculatePartSize.mjs +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/calculatePartSize.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/getDataChunker.d.ts +1 -1
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/getDataChunker.mjs +2 -2
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/getDataChunker.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/initialUpload.d.ts +3 -3
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/initialUpload.mjs +15 -15
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/initialUpload.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/progressTracker.d.ts +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/progressTracker.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadCache.d.ts +2 -2
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadCache.mjs +15 -15
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadCache.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadHandlers.d.ts +4 -3
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadHandlers.mjs +27 -28
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadPartExecutor.d.ts +2 -2
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadPartExecutor.mjs +15 -15
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.d.ts +9 -0
- package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/putObjectJob.mjs +22 -23
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/server/index.d.ts +1 -0
- package/dist/esm/providers/s3/apis/server/index.mjs +1 -0
- package/dist/esm/providers/s3/apis/server/index.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/uploadData.d.ts +4 -0
- package/dist/esm/providers/s3/apis/server/uploadData.mjs +11 -0
- package/dist/esm/providers/s3/apis/server/uploadData.mjs.map +1 -0
- package/dist/esm/providers/s3/apis/uploadData.d.ts +3 -0
- package/dist/esm/providers/s3/apis/uploadData.mjs +11 -0
- package/dist/esm/providers/s3/apis/uploadData.mjs.map +1 -0
- package/dist/esm/providers/s3/index.mjs +1 -1
- package/dist/esm/providers/s3/server.mjs +1 -0
- package/dist/esm/providers/s3/server.mjs.map +1 -1
- package/dist/esm/providers/s3/types/options.d.ts +1 -0
- package/dist/esm/providers/s3/utils/client/getObject.d.ts +6 -2
- package/dist/esm/providers/s3/utils/client/getObject.mjs +1 -1
- package/dist/esm/providers/s3/utils/client/getObject.mjs.map +1 -1
- package/dist/esm/server.mjs +1 -0
- package/dist/esm/server.mjs.map +1 -1
- package/package.json +107 -107
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/index.ts +22 -18
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/calculatePartSize.ts +4 -1
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/getDataChunker.ts +3 -3
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/initialUpload.ts +8 -5
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/progressTracker.ts +1 -1
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadCache.ts +4 -4
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadHandlers.ts +19 -15
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadPartExecutor.ts +5 -5
- package/src/providers/s3/apis/{uploadData → internal/uploadData}/putObjectJob.ts +10 -9
- package/src/providers/s3/apis/server/index.ts +1 -0
- package/src/providers/s3/apis/server/uploadData.ts +35 -0
- package/src/providers/s3/apis/uploadData.ts +23 -0
- package/src/providers/s3/types/options.ts +2 -0
- package/src/providers/s3/utils/client/getObject.ts +3 -3
- package/dist/cjs/providers/s3/apis/uploadData/byteLength.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/index.js +0 -44
- package/dist/cjs/providers/s3/apis/uploadData/index.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/calculatePartSize.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/getDataChunker.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/index.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/initialUpload.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/progressTracker.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadCache.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadHandlers.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/multipart/uploadPartExecutor.js.map +0 -1
- package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/byteLength.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/index.mjs +0 -49
- package/dist/esm/providers/s3/apis/uploadData/index.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/calculatePartSize.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/getDataChunker.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/progressTracker.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadCache.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadHandlers.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/multipart/uploadPartExecutor.mjs.map +0 -1
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.d.ts +0 -8
- package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs.map +0 -1
- /package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/byteLength.js +0 -0
- /package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/index.js +0 -0
- /package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/progressTracker.js +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/byteLength.d.ts +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/byteLength.mjs +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/calculatePartSize.d.ts +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/index.d.ts +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/index.mjs +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/index.mjs.map +0 -0
- /package/dist/esm/providers/s3/apis/{uploadData → internal/uploadData}/multipart/progressTracker.mjs +0 -0
- /package/src/providers/s3/apis/{uploadData → internal/uploadData}/byteLength.ts +0 -0
- /package/src/providers/s3/apis/{uploadData → internal/uploadData}/multipart/index.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byteLength.js","sources":["../../../../../../../src/providers/s3/apis/internal/uploadData/byteLength.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.byteLength = void 0;\n/**\n * Calculate the total size of the data to be uploaded. The total size is not required for multipart upload, as it's\n * only used in progress report.\n */\nconst byteLength = (input) => {\n if (input === null || input === undefined)\n return 0;\n if (typeof input === 'string') {\n let len = input.length;\n for (let i = len - 1; i >= 0; i--) {\n const code = input.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff)\n len++;\n else if (code > 0x7ff && code <= 0xffff)\n len += 2;\n if (code >= 0xdc00 && code <= 0xdfff)\n i--; // trail surrogate\n }\n return len;\n }\n else if (typeof input.byteLength === 'number') {\n // handles Uint8Array, ArrayBuffer, Buffer, and ArrayBufferView\n return input.byteLength;\n }\n else if (typeof input.size === 'number') {\n // handles browser File object\n return input.size;\n }\n // TODO: support Node.js stream size when Node.js runtime is supported out-of-box.\n return undefined;\n};\nexports.byteLength = byteLength;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B;AACA;AACA;AACA;AACA,MAAM,UAAU,GAAG,CAAC,KAAK,KAAK;AAC9B,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;AAC7C,QAAQ,OAAO,CAAC,CAAC;AACjB,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACnC,QAAQ,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;AAC/B,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;AAC3C,YAAY,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC7C,YAAY,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,KAAK;AAC5C,gBAAgB,GAAG,EAAE,CAAC;AACtB,iBAAiB,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,MAAM;AACnD,gBAAgB,GAAG,IAAI,CAAC,CAAC;AACzB,YAAY,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;AAChD,gBAAgB,CAAC,EAAE,CAAC;AACpB,SAAS;AACT,QAAQ,OAAO,GAAG,CAAC;AACnB,KAAK;AACL,SAAS,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,EAAE;AACnD;AACA,QAAQ,OAAO,KAAK,CAAC,UAAU,CAAC;AAChC,KAAK;AACL,SAAS,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC7C;AACA,QAAQ,OAAO,KAAK,CAAC,IAAI,CAAC;AAC1B,KAAK;AACL;AACA,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AACF,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
|
@@ -0,0 +1,156 @@
|
|
|
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.uploadData = void 0;
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const assertValidationError_1 = require("../../../../../errors/utils/assertValidationError");
|
|
9
|
+
const validation_1 = require("../../../../../errors/types/validation");
|
|
10
|
+
const constants_1 = require("../../../utils/constants");
|
|
11
|
+
const byteLength_1 = require("./byteLength");
|
|
12
|
+
const putObjectJob_1 = require("./putObjectJob");
|
|
13
|
+
const multipart_1 = require("./multipart");
|
|
14
|
+
/**
|
|
15
|
+
* Upload data to the specified S3 object path. By default uses single PUT operation to upload if the payload is less than 5MB.
|
|
16
|
+
* Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.
|
|
17
|
+
*
|
|
18
|
+
* Limitations:
|
|
19
|
+
* * Maximum object size is 5TB.
|
|
20
|
+
* * Maximum object size if the size cannot be determined before upload is 50GB.
|
|
21
|
+
*
|
|
22
|
+
* @throws Service: `S3Exception` thrown when checking for existence of the object.
|
|
23
|
+
* @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.
|
|
24
|
+
*
|
|
25
|
+
* @param input - A `UploadDataWithPathInput` object.
|
|
26
|
+
*
|
|
27
|
+
* @returns A cancelable and resumable task exposing result promise from `result`
|
|
28
|
+
* property.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* // Upload a file to s3 bucket
|
|
33
|
+
* await uploadData({ path, data: file, options: {
|
|
34
|
+
* onProgress, // Optional progress callback.
|
|
35
|
+
* } }).result;
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // Cancel a task
|
|
41
|
+
* const uploadTask = uploadData({ path, data: file });
|
|
42
|
+
* //...
|
|
43
|
+
* uploadTask.cancel();
|
|
44
|
+
* try {
|
|
45
|
+
* await uploadTask.result;
|
|
46
|
+
* } catch (error) {
|
|
47
|
+
* if(isCancelError(error)) {
|
|
48
|
+
* // Handle error thrown by task cancelation.
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* // Pause and resume a task
|
|
56
|
+
* const uploadTask = uploadData({ path, data: file });
|
|
57
|
+
* //...
|
|
58
|
+
* uploadTask.pause();
|
|
59
|
+
* //...
|
|
60
|
+
* uploadTask.resume();
|
|
61
|
+
* //...
|
|
62
|
+
* await uploadTask.result;
|
|
63
|
+
* ```
|
|
64
|
+
// */
|
|
65
|
+
// export function uploadData(
|
|
66
|
+
// amplify: AmplifyClassV6,
|
|
67
|
+
// input: UploadDataWithPathInput,
|
|
68
|
+
// ): UploadDataWithPathOutput;
|
|
69
|
+
/**
|
|
70
|
+
* Upload data to the specified S3 object key. By default uses single PUT operation to upload if the payload is less than 5MB.
|
|
71
|
+
* Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.
|
|
72
|
+
*
|
|
73
|
+
* Limitations:
|
|
74
|
+
* * Maximum object size is 5TB.
|
|
75
|
+
* * Maximum object size if the size cannot be determined before upload is 50GB.
|
|
76
|
+
*
|
|
77
|
+
* @deprecated The `key` and `accessLevel` parameters are deprecated and will be removed in next major version.
|
|
78
|
+
* Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/upload/#uploaddata | path} instead.
|
|
79
|
+
*
|
|
80
|
+
* @throws Service: `S3Exception` thrown when checking for existence of the object.
|
|
81
|
+
* @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.
|
|
82
|
+
*
|
|
83
|
+
* @param input - A `UploadDataInput` object.
|
|
84
|
+
*
|
|
85
|
+
* @returns A cancelable and resumable task exposing result promise from the `result` property.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* // Upload a file to s3 bucket
|
|
90
|
+
* await uploadData({ key, data: file, options: {
|
|
91
|
+
* onProgress, // Optional progress callback.
|
|
92
|
+
* } }).result;
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* // Cancel a task
|
|
98
|
+
* const uploadTask = uploadData({ key, data: file });
|
|
99
|
+
* //...
|
|
100
|
+
* uploadTask.cancel();
|
|
101
|
+
* try {
|
|
102
|
+
* await uploadTask.result;
|
|
103
|
+
* } catch (error) {
|
|
104
|
+
* if(isCancelError(error)) {
|
|
105
|
+
* // Handle error thrown by task cancelation.
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
*```
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* // Pause and resume a task
|
|
113
|
+
* const uploadTask = uploadData({ key, data: file });
|
|
114
|
+
* //...
|
|
115
|
+
* uploadTask.pause();
|
|
116
|
+
* //...
|
|
117
|
+
* uploadTask.resume();
|
|
118
|
+
* //...
|
|
119
|
+
* await uploadTask.result;
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
// export function uploadData(
|
|
123
|
+
// amplify: AmplifyClassV6,
|
|
124
|
+
// input: UploadDataInput,
|
|
125
|
+
// ): UploadDataOutput;
|
|
126
|
+
function uploadData(amplify, input) {
|
|
127
|
+
const { data } = input;
|
|
128
|
+
const dataByteLength = (0, byteLength_1.byteLength)(data);
|
|
129
|
+
(0, assertValidationError_1.assertValidationError)(dataByteLength === undefined || dataByteLength <= constants_1.MAX_OBJECT_SIZE, validation_1.StorageValidationErrorCode.ObjectIsTooLarge);
|
|
130
|
+
if (dataByteLength && dataByteLength <= constants_1.DEFAULT_PART_SIZE) {
|
|
131
|
+
// Single part upload
|
|
132
|
+
const abortController = new AbortController();
|
|
133
|
+
return (0, utils_1.createUploadTask)({
|
|
134
|
+
isMultipartUpload: false,
|
|
135
|
+
job: (0, putObjectJob_1.putObjectJob)(amplify, input, abortController.signal, dataByteLength),
|
|
136
|
+
onCancel: (message) => {
|
|
137
|
+
abortController.abort(message);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Multipart upload
|
|
143
|
+
const { multipartUploadJob, onPause, onResume, onCancel } = (0, multipart_1.getMultipartUploadHandlers)(amplify, input, dataByteLength);
|
|
144
|
+
return (0, utils_1.createUploadTask)({
|
|
145
|
+
isMultipartUpload: true,
|
|
146
|
+
job: multipartUploadJob,
|
|
147
|
+
onCancel: (message) => {
|
|
148
|
+
onCancel(message);
|
|
149
|
+
},
|
|
150
|
+
onPause,
|
|
151
|
+
onResume,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.uploadData = uploadData;
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../src/providers/s3/apis/internal/uploadData/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = void 0;\nconst utils_1 = require(\"../../../utils\");\nconst assertValidationError_1 = require(\"../../../../../errors/utils/assertValidationError\");\nconst validation_1 = require(\"../../../../../errors/types/validation\");\nconst constants_1 = require(\"../../../utils/constants\");\nconst byteLength_1 = require(\"./byteLength\");\nconst putObjectJob_1 = require(\"./putObjectJob\");\nconst multipart_1 = require(\"./multipart\");\n/**\n * Upload data to the specified S3 object path. By default uses single PUT operation to upload if the payload is less than 5MB.\n * Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.\n *\n * Limitations:\n * * Maximum object size is 5TB.\n * * Maximum object size if the size cannot be determined before upload is 50GB.\n *\n * @throws Service: `S3Exception` thrown when checking for existence of the object.\n * @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.\n *\n * @param input - A `UploadDataWithPathInput` object.\n *\n * @returns A cancelable and resumable task exposing result promise from `result`\n * \tproperty.\n *\n * @example\n * ```ts\n * // Upload a file to s3 bucket\n * await uploadData({ path, data: file, options: {\n * onProgress, // Optional progress callback.\n * } }).result;\n * ```\n *\n * @example\n * ```ts\n * // Cancel a task\n * const uploadTask = uploadData({ path, data: file });\n * //...\n * uploadTask.cancel();\n * try {\n * await uploadTask.result;\n * } catch (error) {\n * if(isCancelError(error)) {\n * // Handle error thrown by task cancelation.\n * }\n * }\n *```\n *\n * @example\n * ```ts\n * // Pause and resume a task\n * const uploadTask = uploadData({ path, data: file });\n * //...\n * uploadTask.pause();\n * //...\n * uploadTask.resume();\n * //...\n * await uploadTask.result;\n * ```\n// */\n// export function uploadData(\n// \tamplify: AmplifyClassV6,\n// \tinput: UploadDataWithPathInput,\n// ): UploadDataWithPathOutput;\n/**\n * Upload data to the specified S3 object key. By default uses single PUT operation to upload if the payload is less than 5MB.\n * Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.\n *\n * Limitations:\n * * Maximum object size is 5TB.\n * * Maximum object size if the size cannot be determined before upload is 50GB.\n *\n * @deprecated The `key` and `accessLevel` parameters are deprecated and will be removed in next major version.\n * Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/upload/#uploaddata | path} instead.\n *\n * @throws Service: `S3Exception` thrown when checking for existence of the object.\n * @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.\n *\n * @param input - A `UploadDataInput` object.\n *\n * @returns A cancelable and resumable task exposing result promise from the `result` property.\n *\n * @example\n * ```ts\n * // Upload a file to s3 bucket\n * await uploadData({ key, data: file, options: {\n * onProgress, // Optional progress callback.\n * } }).result;\n * ```\n *\n * @example\n * ```ts\n * // Cancel a task\n * const uploadTask = uploadData({ key, data: file });\n * //...\n * uploadTask.cancel();\n * try {\n * await uploadTask.result;\n * } catch (error) {\n * if(isCancelError(error)) {\n * // Handle error thrown by task cancelation.\n * }\n * }\n *```\n *\n * @example\n * ```ts\n * // Pause and resume a task\n * const uploadTask = uploadData({ key, data: file });\n * //...\n * uploadTask.pause();\n * //...\n * uploadTask.resume();\n * //...\n * await uploadTask.result;\n * ```\n */\n// export function uploadData(\n// \tamplify: AmplifyClassV6,\n// \tinput: UploadDataInput,\n// ): UploadDataOutput;\nfunction uploadData(amplify, input) {\n const { data } = input;\n const dataByteLength = (0, byteLength_1.byteLength)(data);\n (0, assertValidationError_1.assertValidationError)(dataByteLength === undefined || dataByteLength <= constants_1.MAX_OBJECT_SIZE, validation_1.StorageValidationErrorCode.ObjectIsTooLarge);\n if (dataByteLength && dataByteLength <= constants_1.DEFAULT_PART_SIZE) {\n // Single part upload\n const abortController = new AbortController();\n return (0, utils_1.createUploadTask)({\n isMultipartUpload: false,\n job: (0, putObjectJob_1.putObjectJob)(amplify, input, abortController.signal, dataByteLength),\n onCancel: (message) => {\n abortController.abort(message);\n },\n });\n }\n else {\n // Multipart upload\n const { multipartUploadJob, onPause, onResume, onCancel } = (0, multipart_1.getMultipartUploadHandlers)(amplify, input, dataByteLength);\n return (0, utils_1.createUploadTask)({\n isMultipartUpload: true,\n job: multipartUploadJob,\n onCancel: (message) => {\n onCancel(message);\n },\n onPause,\n onResume,\n });\n }\n}\nexports.uploadData = uploadData;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,uBAAuB,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvE,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC7C,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE;AACpC,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC3B,IAAI,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC9D,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,cAAc,KAAK,SAAS,IAAI,cAAc,IAAI,WAAW,CAAC,eAAe,EAAE,YAAY,CAAC,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;AAChM,IAAI,IAAI,cAAc,IAAI,cAAc,IAAI,WAAW,CAAC,iBAAiB,EAAE;AAC3E;AACA,QAAQ,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AACtD,QAAQ,OAAO,IAAI,OAAO,CAAC,gBAAgB,EAAE;AAC7C,YAAY,iBAAiB,EAAE,KAAK;AACpC,YAAY,GAAG,EAAE,IAAI,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC;AACzG,YAAY,QAAQ,EAAE,CAAC,OAAO,KAAK;AACnC,gBAAgB,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,SAAS;AACT;AACA,QAAQ,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,WAAW,CAAC,0BAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;AAChJ,QAAQ,OAAO,IAAI,OAAO,CAAC,gBAAgB,EAAE;AAC7C,YAAY,iBAAiB,EAAE,IAAI;AACnC,YAAY,GAAG,EAAE,kBAAkB;AACnC,YAAY,QAAQ,EAAE,CAAC,OAAO,KAAK;AACnC,gBAAgB,QAAQ,CAAC,OAAO,CAAC,CAAC;AAClC,aAAa;AACb,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/calculatePartSize.js
RENAMED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.calculatePartSize = void 0;
|
|
7
|
-
const constants_1 = require("
|
|
7
|
+
const constants_1 = require("../../../../utils/constants");
|
|
8
8
|
const calculatePartSize = (totalSize) => {
|
|
9
9
|
if (!totalSize) {
|
|
10
10
|
return constants_1.DEFAULT_PART_SIZE;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculatePartSize.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/calculatePartSize.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.calculatePartSize = void 0;\nconst constants_1 = require(\"../../../../utils/constants\");\nconst calculatePartSize = (totalSize) => {\n if (!totalSize) {\n return constants_1.DEFAULT_PART_SIZE;\n }\n let partSize = constants_1.DEFAULT_PART_SIZE;\n let partsCount = Math.ceil(totalSize / partSize);\n while (partsCount > constants_1.MAX_PARTS_COUNT) {\n partSize *= 2;\n partsCount = Math.ceil(totalSize / partSize);\n }\n return partSize;\n};\nexports.calculatePartSize = calculatePartSize;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC3D,MAAM,iBAAiB,GAAG,CAAC,SAAS,KAAK;AACzC,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,OAAO,WAAW,CAAC,iBAAiB,CAAC;AAC7C,KAAK;AACL,IAAI,IAAI,QAAQ,GAAG,WAAW,CAAC,iBAAiB,CAAC;AACjD,IAAI,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;AACrD,IAAI,OAAO,UAAU,GAAG,WAAW,CAAC,eAAe,EAAE;AACrD,QAAQ,QAAQ,IAAI,CAAC,CAAC;AACtB,QAAQ,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;AACrD,KAAK;AACL,IAAI,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AACF,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
|
package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/getDataChunker.js
RENAMED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getDataChunker = void 0;
|
|
7
|
-
const validation_1 = require("
|
|
8
|
-
const StorageError_1 = require("
|
|
7
|
+
const validation_1 = require("../../../../../../errors/types/validation");
|
|
8
|
+
const StorageError_1 = require("../../../../../../errors/StorageError");
|
|
9
9
|
const calculatePartSize_1 = require("./calculatePartSize");
|
|
10
10
|
const getDataChunker = (data, totalSize) => {
|
|
11
11
|
const partSize = (0, calculatePartSize_1.calculatePartSize)(totalSize);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDataChunker.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/getDataChunker.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.getDataChunker = void 0;\nconst validation_1 = require(\"../../../../../../errors/types/validation\");\nconst StorageError_1 = require(\"../../../../../../errors/StorageError\");\nconst calculatePartSize_1 = require(\"./calculatePartSize\");\nconst getDataChunker = (data, totalSize) => {\n const partSize = (0, calculatePartSize_1.calculatePartSize)(totalSize);\n if (data instanceof Blob) {\n return helper(data, 0, data.size, partSize);\n }\n else if (ArrayBuffer.isView(data)) {\n return helper(data.buffer, data.byteOffset, data.byteLength, partSize);\n }\n else if (data instanceof ArrayBuffer) {\n return helper(data, 0, data.byteLength, partSize);\n }\n else if (typeof data === 'string') {\n const blob = new Blob([data]);\n return (0, exports.getDataChunker)(blob, blob.size);\n }\n else {\n throw new StorageError_1.StorageError({\n name: validation_1.StorageValidationErrorCode.InvalidUploadSource,\n ...validation_1.validationErrorMap[validation_1.StorageValidationErrorCode.InvalidUploadSource],\n });\n }\n};\nexports.getDataChunker = getDataChunker;\nconst helper = function* (buffer, byteOffset, byteLength, partSize) {\n let partNumber = 1;\n let startByte = byteOffset;\n let endByte = byteOffset + Math.min(partSize, byteLength);\n while (endByte < byteLength + byteOffset) {\n yield {\n partNumber,\n data: buffer.slice(startByte, endByte),\n size: partSize,\n };\n partNumber += 1;\n startByte = endByte;\n endByte = startByte + partSize;\n }\n yield {\n partNumber,\n data: buffer.slice(startByte, byteLength + byteOffset),\n size: byteLength + byteOffset - startByte,\n };\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,YAAY,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AAC1E,MAAM,cAAc,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC;AACxE,MAAM,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC3D,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK;AAC5C,IAAI,MAAM,QAAQ,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAC3E,IAAI,IAAI,IAAI,YAAY,IAAI,EAAE;AAC9B,QAAQ,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpD,KAAK;AACL,SAAS,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AACvC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC/E,KAAK;AACL,SAAS,IAAI,IAAI,YAAY,WAAW,EAAE;AAC1C,QAAQ,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC1D,KAAK;AACL,SAAS,IAAI,OAAO,IAAI,KAAK,QAAQ,E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AAQ,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS;AACjD,KAAK,CAAC;AACN,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/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.getMultipartUploadHandlers = void 0;\nvar uploadHandlers_1 = require(\"./uploadHandlers\");\nObject.defineProperty(exports, \"getMultipartUploadHandlers\", { enumerable: true, get: function () { return uploadHandlers_1.getMultipartUploadHandlers; } });\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,IAAI,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACnD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,gBAAgB,CAAC,0BAA0B,CAAC,EAAE,EAAE,CAAC;;"}
|
package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/initialUpload.js
RENAMED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.loadOrCreateMultipartUpload = void 0;
|
|
7
|
-
const client_1 = require("
|
|
8
|
-
const utils_1 = require("
|
|
9
|
-
const constructContentDisposition_1 = require("
|
|
7
|
+
const client_1 = require("../../../../utils/client");
|
|
8
|
+
const utils_1 = require("../../../../../../utils");
|
|
9
|
+
const constructContentDisposition_1 = require("../../../../utils/constructContentDisposition");
|
|
10
10
|
const uploadCache_1 = require("./uploadCache");
|
|
11
11
|
/**
|
|
12
12
|
* Load the in-progress multipart upload from local storage or async storage(RN) if it exists, or create a new multipart
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialUpload.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/initialUpload.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.loadOrCreateMultipartUpload = void 0;\nconst client_1 = require(\"../../../../utils/client\");\nconst utils_1 = require(\"../../../../../../utils\");\nconst constructContentDisposition_1 = require(\"../../../../utils/constructContentDisposition\");\nconst uploadCache_1 = require(\"./uploadCache\");\n/**\n * Load the in-progress multipart upload from local storage or async storage(RN) if it exists, or create a new multipart\n * upload.\n *\n * @internal\n */\nconst loadOrCreateMultipartUpload = async ({ s3Config, data, size, contentType, bucket, accessLevel, keyPrefix, key, contentDisposition, contentEncoding, metadata, abortSignal, }) => {\n const finalKey = keyPrefix !== undefined ? keyPrefix + key : key;\n let cachedUpload;\n if (size === undefined) {\n utils_1.logger.debug('uploaded data size cannot be determined, skipping cache.');\n cachedUpload = undefined;\n }\n else {\n const uploadCacheKey = (0, uploadCache_1.getUploadsCacheKey)({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n const cachedUploadParts = await (0, uploadCache_1.findCachedUploadParts)({\n s3Config,\n cacheKey: uploadCacheKey,\n bucket,\n finalKey,\n });\n cachedUpload = cachedUploadParts\n ? { ...cachedUploadParts, uploadCacheKey }\n : undefined;\n }\n if (cachedUpload) {\n return {\n uploadId: cachedUpload.uploadId,\n cachedParts: cachedUpload.parts,\n };\n }\n else {\n const { UploadId } = await (0, client_1.createMultipartUpload)({\n ...s3Config,\n abortSignal,\n }, {\n Bucket: bucket,\n Key: finalKey,\n ContentType: contentType,\n ContentDisposition: (0, constructContentDisposition_1.constructContentDisposition)(contentDisposition),\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n });\n if (size === undefined) {\n utils_1.logger.debug('uploaded data size cannot be determined, skipping cache.');\n return {\n uploadId: UploadId,\n cachedParts: [],\n };\n }\n const uploadCacheKey = (0, uploadCache_1.getUploadsCacheKey)({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n await (0, uploadCache_1.cacheMultipartUpload)(uploadCacheKey, {\n uploadId: UploadId,\n bucket,\n key,\n fileName: data instanceof File ? data.name : '',\n });\n return {\n uploadId: UploadId,\n cachedParts: [],\n };\n }\n};\nexports.loadOrCreateMultipartUpload = loadOrCreateMultipartUpload;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACrD,MAAM,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACnD,MAAM,6BAA6B,GAAG,OAAO,CAAC,+CAA+C,CAAC,CAAC;AAC/F,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,2BAA2B,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,GAAG,KAAK;AACvL,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC;AACrE,IAAI,IAAI,YAAY,CAAC;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e;AAC5C,YAAY,QAAQ,EAAE,QAAQ;AAC9B,SAAS,CAAC,CAAC;AACX,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE;AAChC,YAAY,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC7F,YAAY,OAAO;AACnB,gBAAgB,QAAQ,EAAE,QAAQ;AAClC,gBAAgB,WAAW,EAAE,EAAE;AAC/B,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,kBAAkB,EAAE;AACrE,YAAY,IAAI;AAChB,YAAY,WAAW;AACvB,YAAY,IAAI,EAAE,IAAI,YAAY,IAAI,GAAG,IAAI,GAAG,SAAS;AACzD,YAAY,MAAM;AAClB,YAAY,WAAW;AACvB,YAAY,GAAG;AACf,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,IAAI,aAAa,CAAC,oBAAoB,EAAE,cAAc,EAAE;AACtE,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,MAAM;AAClB,YAAY,GAAG;AACf,YAAY,QAAQ,EAAE,IAAI,YAAY,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,EAAE;AAC3D,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO;AACf,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,WAAW,EAAE,EAAE;AAC3B,SAAS,CAAC;AACV,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressTracker.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/progressTracker.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.getConcurrentUploadsProgressTracker = void 0;\n/**\n * Track the progress from multiple concurrent uploads, and invoke the onProgress callback.\n *\n * @internal\n */\nconst getConcurrentUploadsProgressTracker = ({ size, onProgress, }) => {\n const transferredBytesPerListener = [];\n const getTransferredBytes = () => transferredBytesPerListener.reduce((acc, transferredBytes) => acc + transferredBytes, 0);\n return {\n getOnProgressListener: () => {\n transferredBytesPerListener.push(0);\n const listenerIndex = transferredBytesPerListener.length - 1;\n return (event) => {\n const { transferredBytes } = event;\n transferredBytesPerListener[listenerIndex] = transferredBytes;\n onProgress?.({\n transferredBytes: getTransferredBytes(),\n totalBytes: size,\n });\n };\n },\n };\n};\nexports.getConcurrentUploadsProgressTracker = getConcurrentUploadsProgressTracker;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mCAAmC,GAAG,KAAK,CAAC,CAAC;AACrD;AACA;AACA;AACA;AACA;AACA,MAAM,mCAAmC,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,KAAK;AACvE,IAAI,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC3C,IAAI,MAAM,mBAAmB,GAAG,MAAM,2BAA2B,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,GAAG,GAAG,gBAAgB,EAAE,CAAC,CAAC,CAAC;AAC/H,IAAI,OAAO;AACX,QAAQ,qBAAqB,EAAE,MAAM;AACrC,YAAY,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChD,YAAY,MAAM,aAAa,GAAG,2BAA2B,CAAC,MAAM,GAAG,CAAC,CAAC;AACzE,YAAY,OAAO,CAAC,KAAK,KAAK;AAC9B,gBAAgB,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;AACnD,gBAAgB,2BAA2B,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC;AAC9E,gBAAgB,UAAU,GAAG;AAC7B,oBAAoB,gBAAgB,EAAE,mBAAmB,EAAE;AAC3D,oBAAoB,UAAU,EAAE,IAAI;AACpC,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,SAAS;AACT,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,mCAAmC,GAAG,mCAAmC;;"}
|
package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadCache.js
RENAMED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.removeCachedUpload = exports.cacheMultipartUpload = exports.getUploadsCacheKey = exports.findCachedUploadParts = void 0;
|
|
7
7
|
const core_1 = require("@aws-amplify/core");
|
|
8
|
-
const constants_1 = require("
|
|
9
|
-
const client_1 = require("
|
|
10
|
-
const utils_1 = require("
|
|
8
|
+
const constants_1 = require("../../../../utils/constants");
|
|
9
|
+
const client_1 = require("../../../../utils/client");
|
|
10
|
+
const utils_1 = require("../../../../../../utils");
|
|
11
11
|
const ONE_HOUR = 1000 * 60 * 60;
|
|
12
12
|
/**
|
|
13
13
|
* Find the cached multipart upload id and get the parts that have been uploaded
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadCache.js","sources":["../../../../../../../../src/providers/s3/apis/internal/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,6BAA6B,CAAC,CAAC;AAC3D,MAAM,QAAQ,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACrD,MAAM,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACnD,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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B,QAAQ,GAAG,YAAY;AACvB,QAAQ,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;AAC/B,KAAK,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;;"}
|
package/dist/cjs/providers/s3/apis/{uploadData → internal/uploadData}/multipart/uploadHandlers.js
RENAMED
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getMultipartUploadHandlers = void 0;
|
|
7
|
-
const core_1 = require("@aws-amplify/core");
|
|
8
7
|
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
-
const utils_2 = require("
|
|
10
|
-
const constants_1 = require("
|
|
11
|
-
const StorageError_1 = require("
|
|
12
|
-
const CanceledError_1 = require("
|
|
13
|
-
const client_1 = require("
|
|
14
|
-
const userAgent_1 = require("
|
|
15
|
-
const utils_3 = require("
|
|
8
|
+
const utils_2 = require("../../../../utils");
|
|
9
|
+
const constants_1 = require("../../../../utils/constants");
|
|
10
|
+
const StorageError_1 = require("../../../../../../errors/StorageError");
|
|
11
|
+
const CanceledError_1 = require("../../../../../../errors/CanceledError");
|
|
12
|
+
const client_1 = require("../../../../utils/client");
|
|
13
|
+
const userAgent_1 = require("../../../../utils/userAgent");
|
|
14
|
+
const utils_3 = require("../../../../../../utils");
|
|
16
15
|
const uploadPartExecutor_1 = require("./uploadPartExecutor");
|
|
17
16
|
const uploadCache_1 = require("./uploadCache");
|
|
18
17
|
const progressTracker_1 = require("./progressTracker");
|
|
@@ -24,7 +23,7 @@ const getDataChunker_1 = require("./getDataChunker");
|
|
|
24
23
|
*
|
|
25
24
|
* @internal
|
|
26
25
|
*/
|
|
27
|
-
const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
26
|
+
const getMultipartUploadHandlers = (amplify, uploadDataInput, size) => {
|
|
28
27
|
let resolveCallback;
|
|
29
28
|
let rejectCallback;
|
|
30
29
|
let inProgressUpload;
|
|
@@ -42,7 +41,7 @@ const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
|
42
41
|
let isAbortSignalFromPause = false;
|
|
43
42
|
const startUpload = async () => {
|
|
44
43
|
const { options: uploadDataOptions, data } = uploadDataInput;
|
|
45
|
-
const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
44
|
+
const resolvedS3Options = await (0, utils_2.resolveS3ConfigAndInput)(amplify, uploadDataOptions);
|
|
46
45
|
abortController = new AbortController();
|
|
47
46
|
isAbortSignalFromPause = false;
|
|
48
47
|
resolvedS3Config = resolvedS3Options.s3Config;
|
|
@@ -57,7 +56,7 @@ const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
|
57
56
|
?.accessLevel;
|
|
58
57
|
resolvedKeyPrefix = resolvedS3Options.keyPrefix;
|
|
59
58
|
finalKey = resolvedKeyPrefix + objectKey;
|
|
60
|
-
resolvedAccessLevel = resolveAccessLevel(accessLevel);
|
|
59
|
+
resolvedAccessLevel = resolveAccessLevel(amplify, accessLevel);
|
|
61
60
|
}
|
|
62
61
|
if (!inProgressUpload) {
|
|
63
62
|
const { uploadId, cachedParts } = await (0, initialUpload_1.loadOrCreateMultipartUpload)({
|
|
@@ -208,7 +207,7 @@ const getMultipartUploadHandlers = (uploadDataInput, size) => {
|
|
|
208
207
|
};
|
|
209
208
|
};
|
|
210
209
|
exports.getMultipartUploadHandlers = getMultipartUploadHandlers;
|
|
211
|
-
const resolveAccessLevel = (accessLevel) => accessLevel ??
|
|
212
|
-
|
|
210
|
+
const resolveAccessLevel = (amplify, accessLevel) => accessLevel ??
|
|
211
|
+
amplify.libraryOptions.Storage?.S3?.defaultAccessLevel ??
|
|
213
212
|
constants_1.DEFAULT_ACCESS_LEVEL;
|
|
214
213
|
//# sourceMappingURL=uploadHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadHandlers.js","sources":["../../../../../../../../src/providers/s3/apis/internal/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 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 = (amplify, 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)(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(amplify, 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 = (amplify, accessLevel) => accessLevel ??\n 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;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AC7B,gBAAgB,QAAQ,EAAE,gBAAgB,EAAE,QAAQ;AACpD,aAAa,CAAC,CAAC;AACf,SAAS,CAAC;AACV,QAAQ,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI;AAClC,YAAY,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,CAAC,CAAC,CAAC;AAC1E,SAAS,CAAC,CAAC;AACX,QAAQ,cAAc;AACtB;AACA;AACA,QAAQ,IAAI,eAAe,CAAC,aAAa,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;AAC9E,KAAK,CAAC;AACN,IAAI,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,OAAO,EAAE,WAAW,KAAK,WAAW;AAChE,IAAI,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,EAAE,kBAAkB;AAC1D,IAAI,WAAW,CAAC,oBAAoB;;"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.uploadPartExecutor = void 0;
|
|
7
|
-
const utils_1 = require("
|
|
8
|
-
const client_1 = require("
|
|
9
|
-
const utils_2 = require("
|
|
7
|
+
const utils_1 = require("../../../../utils");
|
|
8
|
+
const client_1 = require("../../../../utils/client");
|
|
9
|
+
const utils_2 = require("../../../../../../utils");
|
|
10
10
|
const uploadPartExecutor = async ({ dataChunkerGenerator, completedPartNumberSet, s3Config, abortSignal, bucket, finalKey, uploadId, onPartUploadCompletion, onProgress, isObjectLockEnabled, }) => {
|
|
11
11
|
let transferredBytes = 0;
|
|
12
12
|
for (const { data, partNumber, size } of dataChunkerGenerator) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadPartExecutor.js","sources":["../../../../../../../../src/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.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.uploadPartExecutor = void 0;\nconst utils_1 = require(\"../../../../utils\");\nconst client_1 = require(\"../../../../utils/client\");\nconst utils_2 = require(\"../../../../../../utils\");\nconst uploadPartExecutor = async ({ dataChunkerGenerator, completedPartNumberSet, s3Config, abortSignal, bucket, finalKey, uploadId, onPartUploadCompletion, onProgress, isObjectLockEnabled, }) => {\n let transferredBytes = 0;\n for (const { data, partNumber, size } of dataChunkerGenerator) {\n if (abortSignal.aborted) {\n utils_2.logger.debug('upload executor aborted.');\n break;\n }\n if (completedPartNumberSet.has(partNumber)) {\n utils_2.logger.debug(`part ${partNumber} already uploaded.`);\n transferredBytes += size;\n onProgress?.({\n transferredBytes,\n });\n }\n else {\n // handle cancel error\n const { ETag: eTag } = await (0, client_1.uploadPart)({\n ...s3Config,\n abortSignal,\n onUploadProgress: (event) => {\n const { transferredBytes: currentPartTransferredBytes } = event;\n onProgress?.({\n transferredBytes: transferredBytes + currentPartTransferredBytes,\n });\n },\n }, {\n Bucket: bucket,\n Key: finalKey,\n UploadId: uploadId,\n Body: data,\n PartNumber: partNumber,\n ContentMD5: isObjectLockEnabled\n ? await (0, utils_1.calculateContentMd5)(data)\n : undefined,\n });\n transferredBytes += size;\n // eTag will always be set even the S3 model interface marks it as optional.\n onPartUploadCompletion(partNumber, eTag);\n }\n }\n};\nexports.uploadPartExecutor = uploadPartExecutor;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;A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AK,CAAC;AACpF,oBAAoB,UAAU,GAAG;AACjC,wBAAwB,gBAAgB,EAAE,gBAAgB,GAAG,2BAA2B;AACxF,qBAAqB,CAAC,CAAC;AACvB,iBAAiB;AACjB,aAAa,EAAE;AACf,gBAAgB,MAAM,EAAE,MAAM;AAC9B,gBAAgB,GAAG,EAAE,QAAQ;AAC7B,gBAAgB,QAAQ,EAAE,QAAQ;AAClC,gBAAgB,IAAI,EAAE,IAAI;AAC1B,gBAAgB,UAAU,EAAE,UAAU;AACtC,gBAAgB,UAAU,EAAE,mBAAmB;AAC/C,sBAAsB,MAAM,IAAI,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC;AAClE,sBAAsB,SAAS;AAC/B,aAAa,CAAC,CAAC;AACf,YAAY,gBAAgB,IAAI,IAAI,CAAC;AACrC;AACA,YAAY,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACrD,SAAS;AACT,KAAK;AACL,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.putObjectJob = void 0;
|
|
7
|
-
const core_1 = require("@aws-amplify/core");
|
|
8
7
|
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
-
const utils_2 = require("
|
|
10
|
-
const client_1 = require("
|
|
11
|
-
const userAgent_1 = require("
|
|
12
|
-
const constants_1 = require("
|
|
13
|
-
const constructContentDisposition_1 = require("
|
|
8
|
+
const utils_2 = require("../../../utils");
|
|
9
|
+
const client_1 = require("../../../utils/client");
|
|
10
|
+
const userAgent_1 = require("../../../utils/userAgent");
|
|
11
|
+
const constants_1 = require("../../../utils/constants");
|
|
12
|
+
const constructContentDisposition_1 = require("../../../utils/constructContentDisposition");
|
|
14
13
|
/**
|
|
15
14
|
* Get a function the returns a promise to call putObject API to S3.
|
|
16
15
|
*
|
|
17
16
|
* @internal
|
|
18
17
|
*/
|
|
19
|
-
const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {
|
|
18
|
+
const putObjectJob = (amplify, uploadDataInput, abortSignal, totalLength) => async () => {
|
|
20
19
|
const { options: uploadDataOptions, data } = uploadDataInput;
|
|
21
|
-
const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(
|
|
20
|
+
const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, uploadDataOptions);
|
|
22
21
|
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, identityId);
|
|
23
22
|
const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
|
|
24
23
|
const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"putObjectJob.js","sources":["../../../../../../../src/providers/s3/apis/internal/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 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\");\nconst constructContentDisposition_1 = require(\"../../../utils/constructContentDisposition\");\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nconst putObjectJob = (amplify, uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(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: (0, constructContentDisposition_1.constructContentDisposition)(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,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,WAAW,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACxD,MAAM,6BAA6B,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AAC5F;AACA;AACA;AACA;AACA;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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;;"}
|
|
@@ -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.copy = exports.remove = exports.list = exports.getUrl = exports.getProperties = void 0;
|
|
6
|
+
exports.uploadData = exports.copy = exports.remove = exports.list = exports.getUrl = exports.getProperties = void 0;
|
|
7
7
|
var getProperties_1 = require("./getProperties");
|
|
8
8
|
Object.defineProperty(exports, "getProperties", { enumerable: true, get: function () { return getProperties_1.getProperties; } });
|
|
9
9
|
var getUrl_1 = require("./getUrl");
|
|
@@ -14,4 +14,6 @@ var remove_1 = require("./remove");
|
|
|
14
14
|
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return remove_1.remove; } });
|
|
15
15
|
var copy_1 = require("./copy");
|
|
16
16
|
Object.defineProperty(exports, "copy", { enumerable: true, get: function () { return copy_1.copy; } });
|
|
17
|
+
var uploadData_1 = require("./uploadData");
|
|
18
|
+
Object.defineProperty(exports, "uploadData", { enumerable: true, get: function () { return uploadData_1.uploadData; } });
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/providers/s3/apis/server/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.copy = exports.remove = exports.list = exports.getUrl = exports.getProperties = void 0;\nvar getProperties_1 = require(\"./getProperties\");\nObject.defineProperty(exports, \"getProperties\", { enumerable: true, get: function () { return getProperties_1.getProperties; } });\nvar getUrl_1 = require(\"./getUrl\");\nObject.defineProperty(exports, \"getUrl\", { enumerable: true, get: function () { return getUrl_1.getUrl; } });\nvar list_1 = require(\"./list\");\nObject.defineProperty(exports, \"list\", { enumerable: true, get: function () { return list_1.list; } });\nvar remove_1 = require(\"./remove\");\nObject.defineProperty(exports, \"remove\", { enumerable: true, get: function () { return remove_1.remove; } });\nvar copy_1 = require(\"./copy\");\nObject.defineProperty(exports, \"copy\", { enumerable: true, get: function () { return copy_1.copy; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/providers/s3/apis/server/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = exports.copy = exports.remove = exports.list = exports.getUrl = exports.getProperties = void 0;\nvar getProperties_1 = require(\"./getProperties\");\nObject.defineProperty(exports, \"getProperties\", { enumerable: true, get: function () { return getProperties_1.getProperties; } });\nvar getUrl_1 = require(\"./getUrl\");\nObject.defineProperty(exports, \"getUrl\", { enumerable: true, get: function () { return getUrl_1.getUrl; } });\nvar list_1 = require(\"./list\");\nObject.defineProperty(exports, \"list\", { enumerable: true, get: function () { return list_1.list; } });\nvar remove_1 = require(\"./remove\");\nObject.defineProperty(exports, \"remove\", { enumerable: true, get: function () { return remove_1.remove; } });\nvar copy_1 = require(\"./copy\");\nObject.defineProperty(exports, \"copy\", { enumerable: true, get: function () { return copy_1.copy; } });\nvar uploadData_1 = require(\"./uploadData\");\nObject.defineProperty(exports, \"uploadData\", { enumerable: true, get: function () { return uploadData_1.uploadData; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACpH,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAClI,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7G,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACvG,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7G,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACvG,IAAI,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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.uploadData = void 0;
|
|
7
|
+
const adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
|
|
8
|
+
const uploadData_1 = require("../internal/uploadData");
|
|
9
|
+
function uploadData(contextSpec, input) {
|
|
10
|
+
return (0, uploadData_1.uploadData)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
|
|
11
|
+
}
|
|
12
|
+
exports.uploadData = uploadData;
|
|
13
|
+
//# sourceMappingURL=uploadData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadData.js","sources":["../../../../../../src/providers/s3/apis/server/uploadData.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = void 0;\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst uploadData_1 = require(\"../internal/uploadData\");\nfunction uploadData(contextSpec, input) {\n return (0, uploadData_1.uploadData)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);\n}\nexports.uploadData = uploadData;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACvD,SAAS,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE;AACxC,IAAI,OAAO,IAAI,YAAY,CAAC,UAAU,EAAE,IAAI,cAAc,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACjH,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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.uploadData = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const uploadData_1 = require("./internal/uploadData");
|
|
9
|
+
function uploadData(input) {
|
|
10
|
+
return (0, uploadData_1.uploadData)(core_1.Amplify, input);
|
|
11
|
+
}
|
|
12
|
+
exports.uploadData = uploadData;
|
|
13
|
+
//# sourceMappingURL=uploadData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadData.js","sources":["../../../../../src/providers/s3/apis/uploadData.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uploadData = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst uploadData_1 = require(\"./internal/uploadData\");\nfunction uploadData(input) {\n return (0, uploadData_1.uploadData)(core_1.Amplify, input);\n}\nexports.uploadData = uploadData;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACtD,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,IAAI,OAAO,IAAI,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU;;"}
|
|
@@ -15,7 +15,7 @@ const getObjectSerializer = async (input, endpoint) => {
|
|
|
15
15
|
(0, utils_2.validateS3RequiredParameter)(!!input.Key, 'Key');
|
|
16
16
|
url.pathname = (0, utils_2.serializePathnameObjectKey)(url, input.Key);
|
|
17
17
|
return {
|
|
18
|
-
method: 'GET',
|
|
18
|
+
method: input.method ?? 'GET',
|
|
19
19
|
headers: {
|
|
20
20
|
...(input.Range && { Range: input.Range }),
|
|
21
21
|
},
|