@aws-amplify/storage 6.5.4 → 6.5.5-unstable.d7522e4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/cjs/providers/s3/apis/internal/getUrl.js +7 -0
  2. package/dist/cjs/providers/s3/apis/internal/getUrl.js.map +1 -1
  3. package/dist/cjs/providers/s3/apis/uploadData/multipart/initialUpload.js +2 -1
  4. package/dist/cjs/providers/s3/apis/uploadData/multipart/initialUpload.js.map +1 -1
  5. package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js +2 -1
  6. package/dist/cjs/providers/s3/apis/uploadData/putObjectJob.js.map +1 -1
  7. package/dist/cjs/providers/s3/utils/client/getObject.js +6 -0
  8. package/dist/cjs/providers/s3/utils/client/getObject.js.map +1 -1
  9. package/dist/cjs/providers/s3/utils/constructContentDisposition.js +16 -0
  10. package/dist/cjs/providers/s3/utils/constructContentDisposition.js.map +1 -0
  11. package/dist/esm/providers/s3/apis/internal/getUrl.mjs +7 -0
  12. package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
  13. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.d.ts +2 -2
  14. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.mjs +2 -1
  15. package/dist/esm/providers/s3/apis/uploadData/multipart/initialUpload.mjs.map +1 -1
  16. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs +2 -1
  17. package/dist/esm/providers/s3/apis/uploadData/putObjectJob.mjs.map +1 -1
  18. package/dist/esm/providers/s3/types/options.d.ts +25 -1
  19. package/dist/esm/providers/s3/utils/client/getObject.d.ts +1 -1
  20. package/dist/esm/providers/s3/utils/client/getObject.mjs +6 -0
  21. package/dist/esm/providers/s3/utils/client/getObject.mjs.map +1 -1
  22. package/dist/esm/providers/s3/utils/constructContentDisposition.d.ts +2 -0
  23. package/dist/esm/providers/s3/utils/constructContentDisposition.mjs +13 -0
  24. package/dist/esm/providers/s3/utils/constructContentDisposition.mjs.map +1 -0
  25. package/package.json +107 -107
  26. package/src/providers/s3/apis/internal/getUrl.ts +9 -0
  27. package/src/providers/s3/apis/uploadData/multipart/initialUpload.ts +4 -3
  28. package/src/providers/s3/apis/uploadData/putObjectJob.ts +2 -1
  29. package/src/providers/s3/types/options.ts +26 -1
  30. package/src/providers/s3/utils/client/getObject.ts +14 -1
  31. package/src/providers/s3/utils/constructContentDisposition.ts +16 -0
@@ -10,6 +10,7 @@ const client_1 = require("../../utils/client");
10
10
  const utils_2 = require("../../utils");
11
11
  const assertValidationError_1 = require("../../../../errors/utils/assertValidationError");
12
12
  const constants_1 = require("../../utils/constants");
13
+ const constructContentDisposition_1 = require("../../utils/constructContentDisposition");
13
14
  const getProperties_1 = require("./getProperties");
14
15
  const getUrl = async (amplify, input) => {
15
16
  const { options: getUrlOptions } = input;
@@ -39,6 +40,12 @@ const getUrl = async (amplify, input) => {
39
40
  }, {
40
41
  Bucket: bucket,
41
42
  Key: finalKey,
43
+ ...(getUrlOptions?.contentDisposition && {
44
+ ResponseContentDisposition: (0, constructContentDisposition_1.constructContentDisposition)(getUrlOptions.contentDisposition),
45
+ }),
46
+ ...(getUrlOptions?.contentType && {
47
+ ResponseContentType: getUrlOptions.contentType,
48
+ }),
42
49
  }),
43
50
  expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),
44
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getUrl.js","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst client_1 = require(\"../../utils/client\");\nconst utils_2 = require(\"../../utils\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst constants_1 = require(\"../../utils/constants\");\nconst getProperties_1 = require(\"./getProperties\");\nconst getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, getUrlOptions);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await (0, getProperties_1.getProperties)(amplify, input, utils_1.StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? constants_1.DEFAULT_PRESIGN_EXPIRATION;\n const resolvedCredential = typeof s3Config.credentials === 'function'\n ? await s3Config.credentials()\n : s3Config.credentials;\n const awsCredExpiration = resolvedCredential.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = constants_1.MAX_URL_EXPIRATION / 1000;\n (0, assertValidationError_1.assertValidationError)(urlExpirationInSec <= maxUrlExpirationInSec, validation_1.StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await (0, client_1.getPresignedGetObjectUrl)({\n ...s3Config,\n credentials: resolvedCredential,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\nexports.getUrl = getUrl;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAA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,CAAC,WAAW,CAAC;AAC/B,IAAI,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,UAAU,CAAC;AAC5D,IAAI,IAAI,iBAAiB,EAAE;AAC3B,QAAQ,MAAM,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,CAAC;AACrG,QAAQ,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;AAClF,KAAK;AACL,IAAI,MAAM,qBAAqB,GAAG,WAAW,CAAC,kBAAkB,GAAG,IAAI,CAAC;AACxE,IAAI,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,YAAY,CAAC,0BAA0B,CAAC,2BAA2B,CAAC,CAAC;AACzK;AACA,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE;AAC1D,YAAY,GAAG,QAAQ;AACvB,YAAY,WAAW,EAAE,kBAAkB;AAC3C,YAAY,UAAU,EAAE,kBAAkB;AAC1C,SAAS,EAAE;AACX,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,EAAE,QAAQ;AACzB,SAAS,CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,MAAM;;"}
1
+ {"version":3,"file":"getUrl.js","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst client_1 = require(\"../../utils/client\");\nconst utils_2 = require(\"../../utils\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst constants_1 = require(\"../../utils/constants\");\nconst constructContentDisposition_1 = require(\"../../utils/constructContentDisposition\");\nconst getProperties_1 = require(\"./getProperties\");\nconst getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, getUrlOptions);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await (0, getProperties_1.getProperties)(amplify, input, utils_1.StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? constants_1.DEFAULT_PRESIGN_EXPIRATION;\n const resolvedCredential = typeof s3Config.credentials === 'function'\n ? await s3Config.credentials()\n : s3Config.credentials;\n const awsCredExpiration = resolvedCredential.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = constants_1.MAX_URL_EXPIRATION / 1000;\n (0, assertValidationError_1.assertValidationError)(urlExpirationInSec <= maxUrlExpirationInSec, validation_1.StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await (0, client_1.getPresignedGetObjectUrl)({\n ...s3Config,\n credentials: resolvedCredential,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n ...(getUrlOptions?.contentDisposition && {\n ResponseContentDisposition: (0, constructContentDisposition_1.constructContentDisposition)(getUrlOptions.contentDisposition),\n }),\n ...(getUrlOptions?.contentType && {\n Respon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D,gBAAgB,0BAA0B,EAAE,IAAI,6BAA6B,CAAC,2BAA2B,EAAE,aAAa,CAAC,kBAAkB,CAAC;AAC5I,aAAa,CAAC;AACd,YAAY,IAAI,aAAa,EAAE,WAAW,IAAI;AAC9C,gBAAgB,mBAAmB,EAAE,aAAa,CAAC,WAAW;AAC9D,aAAa,CAAC;AACd,SAAS,CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,MAAM,GAAG,MAAM;;"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadOrCreateMultipartUpload = void 0;
7
7
  const client_1 = require("../../../utils/client");
8
8
  const utils_1 = require("../../../../../utils");
9
+ const constructContentDisposition_1 = require("../../../utils/constructContentDisposition");
9
10
  const uploadCache_1 = require("./uploadCache");
10
11
  /**
11
12
  * Load the in-progress multipart upload from local storage or async storage(RN) if it exists, or create a new multipart
@@ -53,7 +54,7 @@ const loadOrCreateMultipartUpload = async ({ s3Config, data, size, contentType,
53
54
  Bucket: bucket,
54
55
  Key: finalKey,
55
56
  ContentType: contentType,
56
- ContentDisposition: contentDisposition,
57
+ ContentDisposition: (0, constructContentDisposition_1.constructContentDisposition)(contentDisposition),
57
58
  ContentEncoding: contentEncoding,
58
59
  Metadata: metadata,
59
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"initialUpload.js","sources":["../../../../../../../src/providers/s3/apis/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 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: 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,EAA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,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;;"}
1
+ {"version":3,"file":"initialUpload.js","sources":["../../../../../../../src/providers/s3/apis/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,uBAAuB,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAChD,MAAM,6BAA6B,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AAC5F,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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,EAAE,WAAW;AACpC,YAAY,kBAAkB,EAAE,IAAI,6BAA6B,CAAC,2BAA2B,EAAE,kBAAkB,CAAC;AAClH,YAAY,eAAe,EAAE,eAAe;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;;"}
@@ -10,6 +10,7 @@ const utils_2 = require("../../utils");
10
10
  const client_1 = require("../../utils/client");
11
11
  const userAgent_1 = require("../../utils/userAgent");
12
12
  const constants_1 = require("../../utils/constants");
13
+ const constructContentDisposition_1 = require("../../utils/constructContentDisposition");
13
14
  /**
14
15
  * Get a function the returns a promise to call putObject API to S3.
15
16
  *
@@ -31,7 +32,7 @@ const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () =>
31
32
  Key: finalKey,
32
33
  Body: data,
33
34
  ContentType: contentType,
34
- ContentDisposition: contentDisposition,
35
+ ContentDisposition: (0, constructContentDisposition_1.constructContentDisposition)(contentDisposition),
35
36
  ContentEncoding: contentEncoding,
36
37
  Metadata: metadata,
37
38
  ContentMD5: isObjectLockEnabled
@@ -1 +1 @@
1
- {"version":3,"file":"putObjectJob.js","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.putObjectJob = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst constants_1 = require(\"../../utils/constants\");\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nconst putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await (0, client_1.putObject)({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: contentDisposition,\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n ContentMD5: isObjectLockEnabled\n ? await (0, utils_2.calculateContentMd5)(data)\n : undefined,\n });\n const result = {\n eTag,\n versionId,\n contentType,\n metadata,\n size: totalLength,\n };\n return inputType === constants_1.STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\nexports.putObjectJob = putObjectJob;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,KAAK,YAAY;AAChF,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACjE,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC3J,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE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AAE,GAAG,MAAM,EAAE;AACvC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;AACzC,CAAC,CAAC;AACF,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
1
+ {"version":3,"file":"putObjectJob.js","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.putObjectJob = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst client_1 = require(\"../../utils/client\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst constants_1 = require(\"../../utils/constants\");\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 = (uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(core_1.Amplify, uploadDataOptions);\n const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(uploadDataInput, identityId);\n const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await (0, client_1.putObject)({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: (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,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACrD,MAAM,6BAA6B,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACzF;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,KAAK,YAAY;AAChF,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACjE,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC3J,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,6BA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AAE,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;;"}
@@ -95,6 +95,12 @@ const getPresignedGetObjectUrl = async (config, input) => {
95
95
  if (config.userAgentValue) {
96
96
  url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);
97
97
  }
98
+ if (input.ResponseContentType) {
99
+ url.searchParams.append('response-content-type', input.ResponseContentType);
100
+ }
101
+ if (input.ResponseContentDisposition) {
102
+ url.searchParams.append('response-content-disposition', input.ResponseContentDisposition);
103
+ }
98
104
  for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {
99
105
  url.searchParams.append(headerName, value);
100
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getObject.js","sources":["../../../../../../src/providers/s3/utils/client/getObject.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.getPresignedGetObjectUrl = exports.getObject = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst composers_1 = require(\"@aws-amplify/core/internals/aws-client-utils/composers\");\nconst base_1 = require(\"./base\");\nconst utils_2 = require(\"./utils\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst getObjectSerializer = async (input, endpoint) => {\n const url = new utils_1.AmplifyUrl(endpoint.url.toString());\n (0, utils_2.validateS3RequiredParameter)(!!input.Key, 'Key');\n url.pathname = (0, utils_2.serializePathnameObjectKey)(url, input.Key);\n return {\n method: 'GET',\n headers: {\n ...(input.Range && { Range: input.Range }),\n },\n url,\n };\n};\nconst getObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = (await (0, utils_2.parseXmlError)(response));\n throw (0, utils_2.buildStorageServiceError)(error, response.statusCode);\n }\n else {\n return {\n ...(0, utils_2.map)(response.headers, {\n DeleteMarker: ['x-amz-delete-marker', utils_2.deserializeBoolean],\n AcceptRanges: 'accept-ranges',\n Expiration: 'x-amz-expiration',\n Restore: 'x-amz-restore',\n LastModified: ['last-modified', utils_2.deserializeTimestamp],\n ContentLength: ['content-length', utils_2.deserializeNumber],\n ETag: 'etag',\n ChecksumCRC32: 'x-amz-checksum-crc32',\n ChecksumCRC32C: 'x-amz-checksum-crc32c',\n ChecksumSHA1: 'x-amz-checksum-sha1',\n ChecksumSHA256: 'x-amz-checksum-sha256',\n MissingMeta: ['x-amz-missing-meta', utils_2.deserializeNumber],\n VersionId: 'x-amz-version-id',\n CacheControl: 'cache-control',\n ContentDisposition: 'content-disposition',\n ContentEncoding: 'content-encoding',\n ContentLanguage: 'content-language',\n ContentRange: 'content-range',\n ContentType: 'content-type',\n Expires: ['expires', utils_2.deserializeTimestamp],\n WebsiteRedirectLocation: 'x-amz-website-redirect-location',\n ServerSideEncryption: 'x-amz-server-side-encryption',\n SSECustomerAlgorithm: 'x-amz-server-side-encryption-customer-algorithm',\n SSECustomerKeyMD5: 'x-amz-server-side-encryption-customer-key-md5',\n SSEKMSKeyId: 'x-amz-server-side-encryption-aws-kms-key-id',\n BucketKeyEnabled: [\n 'x-amz-server-side-encryption-bucket-key-enabled',\n utils_2.deserializeBoolean,\n ],\n StorageClass: 'x-amz-storage-class',\n RequestCharged: 'x-amz-request-charged',\n ReplicationStatus: 'x-amz-replication-status',\n PartsCount: ['x-amz-mp-parts-count', utils_2.deserializeNumber],\n TagCount: ['x-amz-tagging-count', utils_2.deserializeNumber],\n ObjectLockMode: 'x-amz-object-lock-mode',\n ObjectLockRetainUntilDate: [\n 'x-amz-object-lock-retain-until-date',\n utils_2.deserializeTimestamp,\n ],\n ObjectLockLegalHoldStatus: 'x-amz-object-lock-legal-hold',\n }),\n Metadata: (0, utils_2.deserializeMetadata)(response.headers),\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n // @ts-expect-error The body is a CompatibleHttpResponse type because the lower-level handler is XHR instead of\n // fetch, which represents payload in Blob instread of ReadableStream.\n Body: response.body,\n };\n }\n};\nexports.getObject = (0, composers_1.composeServiceApi)(utils_2.s3TransferHandler, getObjectSerializer, getObjectDeserializer, { ...base_1.defaultConfig, responseType: 'blob' });\n/**\n * Get a presigned URL for the `getObject` API.\n *\n * @internal\n */\nconst getPresignedGetObjectUrl = async (config, input) => {\n const endpoint = base_1.defaultConfig.endpointResolver(config, input);\n const { url, headers, method } = await getObjectSerializer(input, endpoint);\n // TODO: set content sha256 query parameter with value of UNSIGNED-PAYLOAD instead of empty hash.\n // It requires changes in presignUrl. Without this change, the generated url still works,\n // but not the same as other tools like AWS SDK and CLI.\n url.searchParams.append(utils_2.CONTENT_SHA256_HEADER, aws_client_utils_1.EMPTY_SHA256_HASH);\n if (config.userAgentValue) {\n url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);\n }\n for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {\n url.searchParams.append(headerName, value);\n }\n return (0, aws_client_utils_1.presignUrl)({ method, url, body: undefined }, {\n signingService: base_1.defaultConfig.service,\n signingRegion: config.region,\n ...base_1.defaultConfig,\n ...config,\n });\n};\nexports.getPresignedGetObjectUrl = getPresignedGetObjectUrl;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;AAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;AACnF,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MA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C;AACjG,IAAI,IAAI,MAAM,CAAC,cAAc,EAAE;AAC/B,QAAQ,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,IAAI,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;AACpG,KAAK;AACL,IAAI,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE;AAClH,QAAQ,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,OAAO,IAAI,kBAAkB,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;AAChF,QAAQ,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,OAAO;AACpD,QAAQ,aAAa,EAAE,MAAM,CAAC,MAAM;AACpC,QAAQ,GAAG,MAAM,CAAC,aAAa;AAC/B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;;"}
1
+ {"version":3,"file":"getObject.js","sources":["../../../../../../src/providers/s3/utils/client/getObject.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.getPresignedGetObjectUrl = exports.getObject = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst composers_1 = require(\"@aws-amplify/core/internals/aws-client-utils/composers\");\nconst base_1 = require(\"./base\");\nconst utils_2 = require(\"./utils\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst getObjectSerializer = async (input, endpoint) => {\n const url = new utils_1.AmplifyUrl(endpoint.url.toString());\n (0, utils_2.validateS3RequiredParameter)(!!input.Key, 'Key');\n url.pathname = (0, utils_2.serializePathnameObjectKey)(url, input.Key);\n return {\n method: 'GET',\n headers: {\n ...(input.Range && { Range: input.Range }),\n },\n url,\n };\n};\nconst getObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = (await (0, utils_2.parseXmlError)(response));\n throw (0, utils_2.buildStorageServiceError)(error, response.statusCode);\n }\n else {\n return {\n ...(0, utils_2.map)(response.headers, {\n DeleteMarker: ['x-amz-delete-marker', utils_2.deserializeBoolean],\n AcceptRanges: 'accept-ranges',\n Expiration: 'x-amz-expiration',\n Restore: 'x-amz-restore',\n LastModified: ['last-modified', utils_2.deserializeTimestamp],\n ContentLength: ['content-length', utils_2.deserializeNumber],\n ETag: 'etag',\n ChecksumCRC32: 'x-amz-checksum-crc32',\n ChecksumCRC32C: 'x-amz-checksum-crc32c',\n ChecksumSHA1: 'x-amz-checksum-sha1',\n ChecksumSHA256: 'x-amz-checksum-sha256',\n MissingMeta: ['x-amz-missing-meta', utils_2.deserializeNumber],\n VersionId: 'x-amz-version-id',\n CacheControl: 'cache-control',\n ContentDisposition: 'content-disposition',\n ContentEncoding: 'content-encoding',\n ContentLanguage: 'content-language',\n ContentRange: 'content-range',\n ContentType: 'content-type',\n Expires: ['expires', utils_2.deserializeTimestamp],\n WebsiteRedirectLocation: 'x-amz-website-redirect-location',\n ServerSideEncryption: 'x-amz-server-side-encryption',\n SSECustomerAlgorithm: 'x-amz-server-side-encryption-customer-algorithm',\n SSECustomerKeyMD5: 'x-amz-server-side-encryption-customer-key-md5',\n SSEKMSKeyId: 'x-amz-server-side-encryption-aws-kms-key-id',\n BucketKeyEnabled: [\n 'x-amz-server-side-encryption-bucket-key-enabled',\n utils_2.deserializeBoolean,\n ],\n StorageClass: 'x-amz-storage-class',\n RequestCharged: 'x-amz-request-charged',\n ReplicationStatus: 'x-amz-replication-status',\n PartsCount: ['x-amz-mp-parts-count', utils_2.deserializeNumber],\n TagCount: ['x-amz-tagging-count', utils_2.deserializeNumber],\n ObjectLockMode: 'x-amz-object-lock-mode',\n ObjectLockRetainUntilDate: [\n 'x-amz-object-lock-retain-until-date',\n utils_2.deserializeTimestamp,\n ],\n ObjectLockLegalHoldStatus: 'x-amz-object-lock-legal-hold',\n }),\n Metadata: (0, utils_2.deserializeMetadata)(response.headers),\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n // @ts-expect-error The body is a CompatibleHttpResponse type because the lower-level handler is XHR instead of\n // fetch, which represents payload in Blob instread of ReadableStream.\n Body: response.body,\n };\n }\n};\nexports.getObject = (0, composers_1.composeServiceApi)(utils_2.s3TransferHandler, getObjectSerializer, getObjectDeserializer, { ...base_1.defaultConfig, responseType: 'blob' });\n/**\n * Get a presigned URL for the `getObject` API.\n *\n * @internal\n */\nconst getPresignedGetObjectUrl = async (config, input) => {\n const endpoint = base_1.defaultConfig.endpointResolver(config, input);\n const { url, headers, method } = await getObjectSerializer(input, endpoint);\n // TODO: set content sha256 query parameter with value of UNSIGNED-PAYLOAD instead of empty hash.\n // It requires changes in presignUrl. Without this change, the generated url still works,\n // but not the same as other tools like AWS SDK and CLI.\n url.searchParams.append(utils_2.CONTENT_SHA256_HEADER, aws_client_utils_1.EMPTY_SHA256_HASH);\n if (config.userAgentValue) {\n url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);\n }\n if (input.ResponseContentType) {\n url.searchParams.append('response-content-type', input.ResponseContentType);\n }\n if (input.ResponseContentDisposition) {\n url.searchParams.append('response-content-disposition', input.ResponseContentDisposition);\n }\n for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {\n url.searchParams.append(headerName, value);\n }\n return (0, aws_client_utils_1.presignUrl)({ method, url, body: undefined }, {\n signingService: base_1.defaultConfig.service,\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AC,UAAU,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;AAChF,QAAQ,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,OAAO;AACpD,QAAQ,aAAa,EAAE,MAAM,CAAC,MAAM;AACpC,QAAQ,GAAG,MAAM,CAAC,aAAa;AAC/B,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;;"}
@@ -0,0 +1,16 @@
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.constructContentDisposition = void 0;
7
+ const constructContentDisposition = (contentDisposition) => {
8
+ if (!contentDisposition)
9
+ return undefined;
10
+ if (typeof contentDisposition === 'string')
11
+ return contentDisposition;
12
+ const { type, filename } = contentDisposition;
13
+ return filename !== undefined ? `${type}; filename="${filename}"` : type;
14
+ };
15
+ exports.constructContentDisposition = constructContentDisposition;
16
+ //# sourceMappingURL=constructContentDisposition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructContentDisposition.js","sources":["../../../../../src/providers/s3/utils/constructContentDisposition.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.constructContentDisposition = void 0;\nconst constructContentDisposition = (contentDisposition) => {\n if (!contentDisposition)\n return undefined;\n if (typeof contentDisposition === 'string')\n return contentDisposition;\n const { type, filename } = contentDisposition;\n return filename !== undefined ? `${type}; filename=\"${filename}\"` : type;\n};\nexports.constructContentDisposition = constructContentDisposition;\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,2BAA2B,GAAG,CAAC,kBAAkB,KAAK;AAC5D,IAAI,IAAI,CAAC,kBAAkB;AAC3B,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,IAAI,OAAO,kBAAkB,KAAK,QAAQ;AAC9C,QAAQ,OAAO,kBAAkB,CAAC;AAClC,IAAI,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC;AAClD,IAAI,OAAO,QAAQ,KAAK,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAC7E,CAAC,CAAC;AACF,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
@@ -23,6 +23,7 @@ import { assertValidationError } from '../../../../errors/utils/assertValidation
23
23
  import '../../../../utils/logger.mjs';
24
24
  import { validateStorageOperationInput } from '../../utils/validateStorageOperationInput.mjs';
25
25
  import { DEFAULT_PRESIGN_EXPIRATION, STORAGE_INPUT_KEY, MAX_URL_EXPIRATION } from '../../utils/constants.mjs';
26
+ import { constructContentDisposition } from '../../utils/constructContentDisposition.mjs';
26
27
  import { getProperties } from './getProperties.mjs';
27
28
 
28
29
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -55,6 +56,12 @@ const getUrl = async (amplify, input) => {
55
56
  }, {
56
57
  Bucket: bucket,
57
58
  Key: finalKey,
59
+ ...(getUrlOptions?.contentDisposition && {
60
+ ResponseContentDisposition: constructContentDisposition(getUrlOptions.contentDisposition),
61
+ }),
62
+ ...(getUrlOptions?.contentType && {
63
+ ResponseContentType: getUrlOptions.contentType,
64
+ }),
58
65
  }),
59
66
  expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),
60
67
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getUrl.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { getPresignedGetObjectUrl } from '../../utils/client';\nimport { resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION, STORAGE_INPUT_KEY, } from '../../utils/constants';\nimport { getProperties } from './getProperties';\nexport const getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, getUrlOptions);\n const { inputType, objectKey } = validateStorageOperationInput(input, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await getProperties(amplify, input, StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;\n const resolvedCredential = typeof s3Config.credentials === 'function'\n ? await s3Config.credentials()\n : s3Config.credentials;\n const awsCredExpiration = resolvedCredential.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = MAX_URL_EXPIRATION / 1000;\n assertValidationError(urlExpirationInSec <= maxUrlExpirationInSec, StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await getPresignedGetObjectUrl({\n ...s3Config,\n credentials: resolvedCredential,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\n"],"names":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AkB,GAAG,IAAI,CAAC;AAC5D,IAAI,qBAAqB,CAAC,kBAAkB,IAAI,qBAAqB,EAAE,0BAA0B,CAAC,2BAA2B,CAAC,CAAC;AAC/H;AACA,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC5C,YAAY,GAAG,QAAQ;AACvB,YAAY,WAAW,EAAE,kBAAkB;AAC3C,YAAY,UAAU,EAAE,kBAAkB;AAC1C,SAAS,EAAE;AACX,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,EAAE,QAAQ;AACzB,SAAS,CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"getUrl.mjs","sources":["../../../../../../src/providers/s3/apis/internal/getUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { getPresignedGetObjectUrl } from '../../utils/client';\nimport { resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { DEFAULT_PRESIGN_EXPIRATION, MAX_URL_EXPIRATION, STORAGE_INPUT_KEY, } from '../../utils/constants';\nimport { constructContentDisposition } from '../../utils/constructContentDisposition';\nimport { getProperties } from './getProperties';\nexport const getUrl = async (amplify, input) => {\n const { options: getUrlOptions } = input;\n const { s3Config, keyPrefix, bucket, identityId } = await resolveS3ConfigAndInput(amplify, getUrlOptions);\n const { inputType, objectKey } = validateStorageOperationInput(input, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n if (getUrlOptions?.validateObjectExistence) {\n await getProperties(amplify, input, StorageAction.GetUrl);\n }\n let urlExpirationInSec = getUrlOptions?.expiresIn ?? DEFAULT_PRESIGN_EXPIRATION;\n const resolvedCredential = typeof s3Config.credentials === 'function'\n ? await s3Config.credentials()\n : s3Config.credentials;\n const awsCredExpiration = resolvedCredential.expiration;\n if (awsCredExpiration) {\n const awsCredExpirationInSec = Math.floor((awsCredExpiration.getTime() - Date.now()) / 1000);\n urlExpirationInSec = Math.min(awsCredExpirationInSec, urlExpirationInSec);\n }\n const maxUrlExpirationInSec = MAX_URL_EXPIRATION / 1000;\n assertValidationError(urlExpirationInSec <= maxUrlExpirationInSec, StorageValidationErrorCode.UrlExpirationMaxLimitExceed);\n // expiresAt is the minimum of credential expiration and url expiration\n return {\n url: await getPresignedGetObjectUrl({\n ...s3Config,\n credentials: resolvedCredential,\n expiration: urlExpirationInSec,\n }, {\n Bucket: bucket,\n Key: finalKey,\n ...(getUrlOptions?.contentDisposition && {\n ResponseContentDisposition: constructContentDisposition(getUrlOptions.contentDisposition),\n }),\n ...(getUrlOptions?.contentType && {\n ResponseContentType: getUrlOptions.contentType,\n }),\n }),\n expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AASY,MAAC,MAAM,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAChD,IAAI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;AAC7C,IAAI,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAC9G,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACtF,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACzF,IAAI,IA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EAAE,WAAW,IAAI;AAC9C,gBAAgB,mBAAmB,EAAE,aAAa,CAAC,WAAW;AAC9D,aAAa,CAAC;AACd,SAAS,CAAC;AACV,QAAQ,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,GAAG,IAAI,CAAC;AACnE,KAAK,CAAC;AACN;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { StorageAccessLevel } from '@aws-amplify/core';
2
- import { ResolvedS3Config } from '../../../types/options';
2
+ import { ContentDisposition, ResolvedS3Config } from '../../../types/options';
3
3
  import { StorageUploadDataPayload } from '../../../../../types';
4
4
  import { Part } from '../../../utils/client';
5
5
  interface LoadOrCreateMultipartUploadOptions {
@@ -10,7 +10,7 @@ interface LoadOrCreateMultipartUploadOptions {
10
10
  keyPrefix?: string;
11
11
  key: string;
12
12
  contentType?: string;
13
- contentDisposition?: string;
13
+ contentDisposition?: string | ContentDisposition;
14
14
  contentEncoding?: string;
15
15
  metadata?: Record<string, string>;
16
16
  size?: number;
@@ -13,6 +13,7 @@ import '../../../utils/client/deleteObject.mjs';
13
13
  import '../../../../../errors/types/validation.mjs';
14
14
  import '@aws-amplify/core/internals/utils';
15
15
  import { logger } from '../../../../../utils/logger.mjs';
16
+ import { constructContentDisposition } from '../../../utils/constructContentDisposition.mjs';
16
17
  import { getUploadsCacheKey, findCachedUploadParts, cacheMultipartUpload } from './uploadCache.mjs';
17
18
 
18
19
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -63,7 +64,7 @@ const loadOrCreateMultipartUpload = async ({ s3Config, data, size, contentType,
63
64
  Bucket: bucket,
64
65
  Key: finalKey,
65
66
  ContentType: contentType,
66
- ContentDisposition: contentDisposition,
67
+ ContentDisposition: constructContentDisposition(contentDisposition),
67
68
  ContentEncoding: contentEncoding,
68
69
  Metadata: metadata,
69
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"initialUpload.mjs","sources":["../../../../../../../src/providers/s3/apis/uploadData/multipart/initialUpload.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createMultipartUpload } from '../../../utils/client';\nimport { logger } from '../../../../../utils';\nimport { cacheMultipartUpload, findCachedUploadParts, getUploadsCacheKey, } from './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 */\nexport const 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 logger.debug('uploaded data size cannot be determined, skipping cache.');\n cachedUpload = undefined;\n }\n else {\n const uploadCacheKey = getUploadsCacheKey({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n const cachedUploadParts = await 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 createMultipartUpload({\n ...s3Config,\n abortSignal,\n }, {\n Bucket: bucket,\n Key: finalKey,\n ContentType: contentType,\n ContentDisposition: contentDisposition,\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n });\n if (size === undefined) {\n logger.debug('uploaded data size cannot be determined, skipping cache.');\n return {\n uploadId: UploadId,\n cachedParts: [],\n };\n }\n const uploadCacheKey = getUploadsCacheKey({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n await cacheMultipartUpload(uploadCacheKey, {\n uploadId: UploadId,\n bucket,\n key,\n fileName: data instanceof File ? data.name : '',\n });\n return {\n uploadId: UploadId,\n cachedParts: [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right Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createMultipartUpload } from '../../../utils/client';\nimport { logger } from '../../../../../utils';\nimport { constructContentDisposition } from '../../../utils/constructContentDisposition';\nimport { cacheMultipartUpload, findCachedUploadParts, getUploadsCacheKey, } from './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 */\nexport const 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 logger.debug('uploaded data size cannot be determined, skipping cache.');\n cachedUpload = undefined;\n }\n else {\n const uploadCacheKey = getUploadsCacheKey({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n const cachedUploadParts = await 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 createMultipartUpload({\n ...s3Config,\n abortSignal,\n }, {\n Bucket: bucket,\n Key: finalKey,\n ContentType: contentType,\n ContentDisposition: constructContentDisposition(contentDisposition),\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n });\n if (size === undefined) {\n logger.debug('uploaded data size cannot be determined, skipping cache.');\n return {\n uploadId: UploadId,\n cachedParts: [],\n };\n }\n const uploadCacheKey = getUploadsCacheKey({\n size,\n contentType,\n file: data instanceof File ? data : undefined,\n bucket,\n accessLevel,\n key,\n });\n await cacheMultipartUpload(uploadCacheKey, {\n uploadId: UploadId,\n bucket,\n key,\n fileName: data instanceof File ? data.name : '',\n });\n return {\n uploadId: UploadId,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Object.mjs';
20
20
  import '../../utils/client/deleteObject.mjs';
21
21
  import { getStorageUserAgentValue } from '../../utils/userAgent.mjs';
22
+ import { constructContentDisposition } from '../../utils/constructContentDisposition.mjs';
22
23
 
23
24
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
24
25
  // SPDX-License-Identifier: Apache-2.0
@@ -43,7 +44,7 @@ const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () =>
43
44
  Key: finalKey,
44
45
  Body: data,
45
46
  ContentType: contentType,
46
- ContentDisposition: contentDisposition,
47
+ ContentDisposition: constructContentDisposition(contentDisposition),
47
48
  ContentEncoding: contentEncoding,
48
49
  Metadata: metadata,
49
50
  ContentMD5: isObjectLockEnabled
@@ -1 +1 @@
1
- {"version":3,"file":"putObjectJob.mjs","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { calculateContentMd5, resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { putObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { STORAGE_INPUT_KEY } from '../../utils/constants';\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nexport const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await resolveS3ConfigAndInput(Amplify, uploadDataOptions);\n const { inputType, objectKey } = validateStorageOperationInput(uploadDataInput, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await putObject({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: getStorageUserAgentValue(StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: contentDisposition,\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n ContentMD5: isObjectLockEnabled\n ? await calculateContentMd5(data)\n : undefined,\n });\n const result = {\n eTag,\n versionId,\n contentType,\n metadata,\n size: totalLength,\n };\n return inputType === STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,KAAK,YAAY;AACvF,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACjE,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACvI,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;AAChG,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACzF,IAAI,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,GAAG,0BAA0B,EAAE,QAAQ,EAAE,UAAU,GAAG,GAAG,iBAAiB,IAAI,EAAE,CAAC;AAC7I,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,MAAM,SAAS,CAAC;AACjE,QAAQ,GAAG,QAAQ;AACnB,QAAQ,WAAW;AACnB,QAAQ,gBAAgB,EAAE,UAAU;AACpC,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,UAAU,CAAC;AAC1E,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,GAAG,EAAE,QAAQ;AACrB,QAAQ,IAAI,EAAE,IAAI;AAClB,QAAQ,WAAW,EAAE,WAAW;AAChC,QAAQ,kBAAkB,EAAE,kBAAkB;AAC9C,QAAQ,eAAe,EAAE,eAAe;AACxC,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,UAAU,EAAE,mBAAmB;AACvC,cAAc,MAAM,mBAAmB,CAAC,IAAI,CAAC;AAC7C,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,iBAAiB;AAC1C,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;AACvC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAAC;AACzC;;;;"}
1
+ {"version":3,"file":"putObjectJob.mjs","sources":["../../../../../../src/providers/s3/apis/uploadData/putObjectJob.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { calculateContentMd5, resolveS3ConfigAndInput, validateStorageOperationInput, } from '../../utils';\nimport { putObject } from '../../utils/client';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { STORAGE_INPUT_KEY } from '../../utils/constants';\nimport { constructContentDisposition } from '../../utils/constructContentDisposition';\n/**\n * Get a function the returns a promise to call putObject API to S3.\n *\n * @internal\n */\nexport const putObjectJob = (uploadDataInput, abortSignal, totalLength) => async () => {\n const { options: uploadDataOptions, data } = uploadDataInput;\n const { bucket, keyPrefix, s3Config, isObjectLockEnabled, identityId } = await resolveS3ConfigAndInput(Amplify, uploadDataOptions);\n const { inputType, objectKey } = validateStorageOperationInput(uploadDataInput, identityId);\n const finalKey = inputType === STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;\n const { contentDisposition, contentEncoding, contentType = 'application/octet-stream', metadata, onProgress, } = uploadDataOptions ?? {};\n const { ETag: eTag, VersionId: versionId } = await putObject({\n ...s3Config,\n abortSignal,\n onUploadProgress: onProgress,\n userAgentValue: getStorageUserAgentValue(StorageAction.UploadData),\n }, {\n Bucket: bucket,\n Key: finalKey,\n Body: data,\n ContentType: contentType,\n ContentDisposition: constructContentDisposition(contentDisposition),\n ContentEncoding: contentEncoding,\n Metadata: metadata,\n ContentMD5: isObjectLockEnabled\n ? await calculateContentMd5(data)\n : undefined,\n });\n const result = {\n eTag,\n versionId,\n contentType,\n metadata,\n size: totalLength,\n };\n return inputType === STORAGE_INPUT_KEY\n ? { key: objectKey, ...result }\n : { path: objectKey, ...result };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,KAAK,YAAY;AACvF,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACjE,IAAI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACvI,IAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,6BAA6B,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;AAChG,IAAI,MAAM,QAAQ,GAAG,SAAS,KAAK,iBAAiB,GAAG,SAAS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a file.
14
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
15
+ */
16
+ export interface ContentDisposition {
17
+ type: 'attachment' | 'inline';
18
+ filename?: string;
19
+ }
12
20
  /** @deprecated This may be removed in the next major version. */
13
21
  type ReadOptions = {
14
22
  /** @deprecated This may be removed in the next major version. */
@@ -85,6 +93,19 @@ export type GetUrlOptions = CommonOptions & {
85
93
  * @default 900 (15 minutes)
86
94
  */
87
95
  expiresIn?: number;
96
+ /**
97
+ * The default content-disposition header value of the file when downloading it.
98
+ * If a string is provided, it will be used as-is.
99
+ * If an object is provided, it will be used to construct the header value
100
+ * based on the ContentDisposition type definition.
101
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
102
+ */
103
+ contentDisposition?: ContentDisposition | string;
104
+ /**
105
+ * The content-type header value of the file when downloading it.
106
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
107
+ */
108
+ contentType?: string;
88
109
  };
89
110
  /** @deprecated Use {@link GetUrlOptionsWithPath} instead. */
90
111
  export type GetUrlOptionsWithKey = ReadOptions & GetUrlOptions;
@@ -99,9 +120,12 @@ export type DownloadDataOptionsWithPath = DownloadDataOptions;
99
120
  export type UploadDataOptions = CommonOptions & TransferOptions & {
100
121
  /**
101
122
  * The default content-disposition header value of the file when downloading it.
123
+ * If a string is provided, it will be used as-is.
124
+ * If an object is provided, it will be used to construct the header value
125
+ * based on the ContentDisposition type definition.
102
126
  * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
103
127
  */
104
- contentDisposition?: string;
128
+ contentDisposition?: ContentDisposition | string;
105
129
  /**
106
130
  * The default content-encoding header value of the file when downloading it.
107
131
  * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
@@ -1,7 +1,7 @@
1
1
  import { Endpoint, HttpResponse, PresignUrlOptions, UserAgentOptions } from '@aws-amplify/core/internals/aws-client-utils';
2
2
  import { S3EndpointResolverOptions } from './base';
3
3
  import type { GetObjectCommandInput, GetObjectCommandOutput } from './types';
4
- export type GetObjectInput = Pick<GetObjectCommandInput, 'Bucket' | 'Key' | 'Range'>;
4
+ export type GetObjectInput = Pick<GetObjectCommandInput, 'Bucket' | 'Key' | 'Range' | 'ResponseContentDisposition' | 'ResponseContentType'>;
5
5
  export type GetObjectOutput = GetObjectCommandOutput;
6
6
  export declare const getObject: (config: {
7
7
  responseType?: "blob" | "text" | undefined;
@@ -99,6 +99,12 @@ const getPresignedGetObjectUrl = async (config, input) => {
99
99
  if (config.userAgentValue) {
100
100
  url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);
101
101
  }
102
+ if (input.ResponseContentType) {
103
+ url.searchParams.append('response-content-type', input.ResponseContentType);
104
+ }
105
+ if (input.ResponseContentDisposition) {
106
+ url.searchParams.append('response-content-disposition', input.ResponseContentDisposition);
107
+ }
102
108
  for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {
103
109
  url.searchParams.append(headerName, value);
104
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getObject.mjs","sources":["../../../../../../src/providers/s3/utils/client/getObject.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { EMPTY_SHA256_HASH, parseMetadata, presignUrl, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { defaultConfig } from './base';\nimport { CONTENT_SHA256_HEADER, buildStorageServiceError, deserializeBoolean, deserializeMetadata, deserializeNumber, deserializeTimestamp, map, parseXmlError, s3TransferHandler, serializePathnameObjectKey, validateS3RequiredParameter, } from './utils';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst getObjectSerializer = async (input, endpoint) => {\n const url = new AmplifyUrl(endpoint.url.toString());\n validateS3RequiredParameter(!!input.Key, 'Key');\n url.pathname = serializePathnameObjectKey(url, input.Key);\n return {\n method: 'GET',\n headers: {\n ...(input.Range && { Range: input.Range }),\n },\n url,\n };\n};\nconst getObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = (await parseXmlError(response));\n throw buildStorageServiceError(error, response.statusCode);\n }\n else {\n return {\n ...map(response.headers, {\n DeleteMarker: ['x-amz-delete-marker', deserializeBoolean],\n AcceptRanges: 'accept-ranges',\n Expiration: 'x-amz-expiration',\n Restore: 'x-amz-restore',\n LastModified: ['last-modified', deserializeTimestamp],\n ContentLength: ['content-length', deserializeNumber],\n ETag: 'etag',\n ChecksumCRC32: 'x-amz-checksum-crc32',\n ChecksumCRC32C: 'x-amz-checksum-crc32c',\n ChecksumSHA1: 'x-amz-checksum-sha1',\n ChecksumSHA256: 'x-amz-checksum-sha256',\n MissingMeta: ['x-amz-missing-meta', deserializeNumber],\n VersionId: 'x-amz-version-id',\n CacheControl: 'cache-control',\n ContentDisposition: 'content-disposition',\n ContentEncoding: 'content-encoding',\n ContentLanguage: 'content-language',\n ContentRange: 'content-range',\n ContentType: 'content-type',\n Expires: ['expires', deserializeTimestamp],\n WebsiteRedirectLocation: 'x-amz-website-redirect-location',\n ServerSideEncryption: 'x-amz-server-side-encryption',\n SSECustomerAlgorithm: 'x-amz-server-side-encryption-customer-algorithm',\n SSECustomerKeyMD5: 'x-amz-server-side-encryption-customer-key-md5',\n SSEKMSKeyId: 'x-amz-server-side-encryption-aws-kms-key-id',\n BucketKeyEnabled: [\n 'x-amz-server-side-encryption-bucket-key-enabled',\n deserializeBoolean,\n ],\n StorageClass: 'x-amz-storage-class',\n RequestCharged: 'x-amz-request-charged',\n ReplicationStatus: 'x-amz-replication-status',\n PartsCount: ['x-amz-mp-parts-count', deserializeNumber],\n TagCount: ['x-amz-tagging-count', deserializeNumber],\n ObjectLockMode: 'x-amz-object-lock-mode',\n ObjectLockRetainUntilDate: [\n 'x-amz-object-lock-retain-until-date',\n deserializeTimestamp,\n ],\n ObjectLockLegalHoldStatus: 'x-amz-object-lock-legal-hold',\n }),\n Metadata: deserializeMetadata(response.headers),\n $metadata: parseMetadata(response),\n // @ts-expect-error The body is a CompatibleHttpResponse type because the lower-level handler is XHR instead of\n // fetch, which represents payload in Blob instread of ReadableStream.\n Body: response.body,\n };\n }\n};\nexport const getObject = composeServiceApi(s3TransferHandler, getObjectSerializer, getObjectDeserializer, { ...defaultConfig, responseType: 'blob' });\n/**\n * Get a presigned URL for the `getObject` API.\n *\n * @internal\n */\nexport const getPresignedGetObjectUrl = async (config, input) => {\n const endpoint = defaultConfig.endpointResolver(config, input);\n const { url, headers, method } = await getObjectSerializer(input, endpoint);\n // TODO: set content sha256 query parameter with value of UNSIGNED-PAYLOAD instead of empty hash.\n // It requires changes in presignUrl. Without this change, the generated url still works,\n // but not the same as other tools like AWS SDK and CLI.\n url.searchParams.append(CONTENT_SHA256_HEADER, EMPTY_SHA256_HASH);\n if (config.userAgentValue) {\n url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);\n }\n for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {\n url.searchParams.append(headerName, value);\n }\n return presignUrl({ method, url, body: undefined }, {\n signingService: defaultConfig.service,\n signingRegion: config.region,\n ...defaultConfig,\n ...config,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAMA,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,mBAAmB,GAAG,OAAO,KAAK,EAAE,QAAQ,KAAK;AACvD,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxD,IAAI,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpD,IAAI,GAAG,CAAC,QAAQ,GAAG,0BAA0B,CAAC,GAAG,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its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { EMPTY_SHA256_HASH, parseMetadata, presignUrl, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { defaultConfig } from './base';\nimport { CONTENT_SHA256_HEADER, buildStorageServiceError, deserializeBoolean, deserializeMetadata, deserializeNumber, deserializeTimestamp, map, parseXmlError, s3TransferHandler, serializePathnameObjectKey, validateS3RequiredParameter, } from './utils';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst getObjectSerializer = async (input, endpoint) => {\n const url = new AmplifyUrl(endpoint.url.toString());\n validateS3RequiredParameter(!!input.Key, 'Key');\n url.pathname = serializePathnameObjectKey(url, input.Key);\n return {\n method: 'GET',\n headers: {\n ...(input.Range && { Range: input.Range }),\n },\n url,\n };\n};\nconst getObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = (await parseXmlError(response));\n throw buildStorageServiceError(error, response.statusCode);\n }\n else {\n return {\n ...map(response.headers, {\n DeleteMarker: ['x-amz-delete-marker', deserializeBoolean],\n AcceptRanges: 'accept-ranges',\n Expiration: 'x-amz-expiration',\n Restore: 'x-amz-restore',\n LastModified: ['last-modified', deserializeTimestamp],\n ContentLength: ['content-length', deserializeNumber],\n ETag: 'etag',\n ChecksumCRC32: 'x-amz-checksum-crc32',\n ChecksumCRC32C: 'x-amz-checksum-crc32c',\n ChecksumSHA1: 'x-amz-checksum-sha1',\n ChecksumSHA256: 'x-amz-checksum-sha256',\n MissingMeta: ['x-amz-missing-meta', deserializeNumber],\n VersionId: 'x-amz-version-id',\n CacheControl: 'cache-control',\n ContentDisposition: 'content-disposition',\n ContentEncoding: 'content-encoding',\n ContentLanguage: 'content-language',\n ContentRange: 'content-range',\n ContentType: 'content-type',\n Expires: ['expires', deserializeTimestamp],\n WebsiteRedirectLocation: 'x-amz-website-redirect-location',\n ServerSideEncryption: 'x-amz-server-side-encryption',\n SSECustomerAlgorithm: 'x-amz-server-side-encryption-customer-algorithm',\n SSECustomerKeyMD5: 'x-amz-server-side-encryption-customer-key-md5',\n SSEKMSKeyId: 'x-amz-server-side-encryption-aws-kms-key-id',\n BucketKeyEnabled: [\n 'x-amz-server-side-encryption-bucket-key-enabled',\n deserializeBoolean,\n ],\n StorageClass: 'x-amz-storage-class',\n RequestCharged: 'x-amz-request-charged',\n ReplicationStatus: 'x-amz-replication-status',\n PartsCount: ['x-amz-mp-parts-count', deserializeNumber],\n TagCount: ['x-amz-tagging-count', deserializeNumber],\n ObjectLockMode: 'x-amz-object-lock-mode',\n ObjectLockRetainUntilDate: [\n 'x-amz-object-lock-retain-until-date',\n deserializeTimestamp,\n ],\n ObjectLockLegalHoldStatus: 'x-amz-object-lock-legal-hold',\n }),\n Metadata: deserializeMetadata(response.headers),\n $metadata: parseMetadata(response),\n // @ts-expect-error The body is a CompatibleHttpResponse type because the lower-level handler is XHR instead of\n // fetch, which represents payload in Blob instread of ReadableStream.\n Body: response.body,\n };\n }\n};\nexport const getObject = composeServiceApi(s3TransferHandler, getObjectSerializer, getObjectDeserializer, { ...defaultConfig, responseType: 'blob' });\n/**\n * Get a presigned URL for the `getObject` API.\n *\n * @internal\n */\nexport const getPresignedGetObjectUrl = async (config, input) => {\n const endpoint = defaultConfig.endpointResolver(config, input);\n const { url, headers, method } = await getObjectSerializer(input, endpoint);\n // TODO: set content sha256 query parameter with value of UNSIGNED-PAYLOAD instead of empty hash.\n // It requires changes in presignUrl. Without this change, the generated url still works,\n // but not the same as other tools like AWS SDK and CLI.\n url.searchParams.append(CONTENT_SHA256_HEADER, EMPTY_SHA256_HASH);\n if (config.userAgentValue) {\n url.searchParams.append(config.userAgentHeader ?? USER_AGENT_HEADER, config.userAgentValue);\n }\n if (input.ResponseContentType) {\n url.searchParams.append('response-content-type', input.ResponseContentType);\n }\n if (input.ResponseContentDisposition) {\n url.searchParams.append('response-content-disposition', input.ResponseContentDisposition);\n }\n for (const [headerName, value] of Object.entries(headers).sort(([key1], [key2]) => key1.localeCompare(key2))) {\n url.searchParams.append(headerName, value);\n }\n return presignUrl({ method, url, body: undefined }, {\n signingService: defaultConfig.service,\n signingRegion: config.region,\n ...defaultConfig,\n ...config,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAMA,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,mBAAmB,GAAG,OAAO,KAAK,EAAE,QAAQ,KAAK;AACvD,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxD,IAAI,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpD,IAAI,GAAG,CAAC,QAAQ,GAAG,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9D,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,KAAK;AACrB,QAAQ,OAAO,EAAE;AACjB,YAAY,IAAI,KAAK,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;AACtD,SAAS;AACT,QAAQ,GAAG;AACX,KAAK,CAAC;AACN,CAAC,CAAC;AACF,MAAM,qBAAqB,GAAG,OAAO,QAAQ,KAAK;AAClD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,IAAI,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtD,QAAQ,MAAM,wBAAwB,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AACnE,KAAK;AACL,SAAS;AACT,QAAQ,OAAO;AACf,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE;AACrC,gBAAgB,YAAY,EAAE,CAAC,qBAAqB,EAAE,kBAA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AuB,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACpF,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,0BAA0B,EAAE;AAC1C,QAAQ,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,8BAA8B,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAClG,KAAK;AACL,IAAI,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE;AAClH,QAAQ,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,OAAO,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;AACxD,QAAQ,cAAc,EAAE,aAAa,CAAC,OAAO;AAC7C,QAAQ,aAAa,EAAE,MAAM,CAAC,MAAM;AACpC,QAAQ,GAAG,aAAa;AACxB,QAAQ,GAAG,MAAM;AACjB,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -0,0 +1,2 @@
1
+ import { ContentDisposition } from '../types/options';
2
+ export declare const constructContentDisposition: (contentDisposition?: string | ContentDisposition) => string | undefined;
@@ -0,0 +1,13 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const constructContentDisposition = (contentDisposition) => {
4
+ if (!contentDisposition)
5
+ return undefined;
6
+ if (typeof contentDisposition === 'string')
7
+ return contentDisposition;
8
+ const { type, filename } = contentDisposition;
9
+ return filename !== undefined ? `${type}; filename="${filename}"` : type;
10
+ };
11
+
12
+ export { constructContentDisposition };
13
+ //# sourceMappingURL=constructContentDisposition.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructContentDisposition.mjs","sources":["../../../../../src/providers/s3/utils/constructContentDisposition.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const constructContentDisposition = (contentDisposition) => {\n if (!contentDisposition)\n return undefined;\n if (typeof contentDisposition === 'string')\n return contentDisposition;\n const { type, filename } = contentDisposition;\n return filename !== undefined ? `${type}; filename=\"${filename}\"` : type;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,2BAA2B,GAAG,CAAC,kBAAkB,KAAK;AACnE,IAAI,IAAI,CAAC,kBAAkB;AAC3B,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,IAAI,OAAO,kBAAkB,KAAK,QAAQ;AAC9C,QAAQ,OAAO,kBAAkB,CAAC;AAClC,IAAI,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC;AAClD,IAAI,OAAO,QAAQ,KAAK,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAC7E;;;;"}
package/package.json CHANGED
@@ -1,109 +1,109 @@
1
1
  {
2
- "name": "@aws-amplify/storage",
3
- "version": "6.5.4",
4
- "description": "Storage category of aws-amplify",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/esm/index.mjs",
7
- "react-native": {
8
- "./dist/cjs/index": "./src/index.ts",
9
- "fast-xml-parser": "fast-xml-parser",
10
- "buffer": "buffer"
11
- },
12
- "typings": "./dist/esm/index.d.ts",
13
- "browser": {
14
- "./dist/esm/providers/s3/utils/client/runtime/base64/index.native.mjs": "./dist/esm/providers/s3/utils/client/runtime/base64/index.browser.mjs",
15
- "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/fetch.mjs": "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/xhr.mjs",
16
- "./dist/esm/providers/s3/utils/client/runtime/xmlParser/pureJs.mjs": "./dist/esm/providers/s3/utils/client/runtime/xmlParser/dom.mjs",
17
- "fast-xml-parser": false,
18
- "buffer": false
19
- },
20
- "sideEffects": false,
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "scripts": {
25
- "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
26
- "build-with-test": "npm test && npm run build",
27
- "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
28
- "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
29
- "build:watch": "npm run build:esm-cjs -- --watch",
30
- "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
31
- "clean": "npm run clean:size && rimraf lib-esm lib dist",
32
- "clean:size": "rimraf dual-publish-tmp tmp*",
33
- "format": "echo \"Not implemented\"",
34
- "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
35
- "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
36
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
37
- },
38
- "typesVersions": {
39
- ">=4.2": {
40
- "s3": [
41
- "./dist/esm/providers/s3/index.d.ts"
42
- ],
43
- "server": [
44
- "./dist/esm/server.d.ts"
45
- ],
46
- "s3/server": [
47
- "./dist/esm/providers/s3/server.d.ts"
48
- ]
49
- }
50
- },
51
- "repository": {
52
- "type": "git",
53
- "url": "https://github.com/aws-amplify/amplify-js.git"
54
- },
55
- "author": "Amazon Web Services",
56
- "license": "Apache-2.0",
57
- "bugs": {
58
- "url": "https://github.com/aws/aws-amplify/issues"
59
- },
60
- "homepage": "https://aws-amplify.github.io/",
61
- "files": [
62
- "dist/cjs",
63
- "dist/esm",
64
- "src",
65
- "server",
66
- "s3"
67
- ],
68
- "dependencies": {
69
- "@aws-sdk/types": "3.398.0",
70
- "@smithy/md5-js": "2.0.7",
71
- "buffer": "4.9.2",
72
- "fast-xml-parser": "^4.4.1",
73
- "tslib": "^2.5.0"
74
- },
75
- "exports": {
76
- ".": {
77
- "types": "./dist/esm/index.d.ts",
78
- "import": "./dist/esm/index.mjs",
79
- "require": "./dist/cjs/index.js",
80
- "react-native": "./src/index.ts"
81
- },
82
- "./server": {
83
- "types": "./dist/esm/server.d.ts",
84
- "import": "./dist/esm/server.mjs",
85
- "require": "./dist/cjs/server.js"
86
- },
87
- "./s3": {
88
- "types": "./dist/esm/providers/s3/index.d.ts",
89
- "import": "./dist/esm/providers/s3/index.mjs",
90
- "require": "./dist/cjs/providers/s3/index.js",
91
- "react-native": "./src/providers/s3/index.ts"
92
- },
93
- "./s3/server": {
94
- "types": "./dist/esm/providers/s3/server.d.ts",
95
- "import": "./dist/esm/providers/s3/server.mjs",
96
- "require": "./dist/cjs/providers/s3/server.js"
97
- },
98
- "./package.json": "./package.json"
99
- },
100
- "peerDependencies": {
101
- "@aws-amplify/core": "^6.1.0"
102
- },
103
- "devDependencies": {
104
- "@aws-amplify/core": "6.3.8",
105
- "@aws-amplify/react-native": "1.1.4",
106
- "typescript": "5.0.2"
107
- },
108
- "gitHead": "3624556dd68af6b538430c5db76d883e656188dc"
2
+ "name": "@aws-amplify/storage",
3
+ "version": "6.5.5-unstable.d7522e4.0+d7522e4",
4
+ "description": "Storage category of aws-amplify",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "react-native": {
8
+ "./dist/cjs/index": "./src/index.ts",
9
+ "fast-xml-parser": "fast-xml-parser",
10
+ "buffer": "buffer"
11
+ },
12
+ "typings": "./dist/esm/index.d.ts",
13
+ "browser": {
14
+ "./dist/esm/providers/s3/utils/client/runtime/base64/index.native.mjs": "./dist/esm/providers/s3/utils/client/runtime/base64/index.browser.mjs",
15
+ "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/fetch.mjs": "./dist/esm/providers/s3/utils/client/runtime/s3TransferHandler/xhr.mjs",
16
+ "./dist/esm/providers/s3/utils/client/runtime/xmlParser/pureJs.mjs": "./dist/esm/providers/s3/utils/client/runtime/xmlParser/dom.mjs",
17
+ "fast-xml-parser": false,
18
+ "buffer": false
19
+ },
20
+ "sideEffects": false,
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
26
+ "build-with-test": "npm test && npm run build",
27
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
28
+ "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
29
+ "build:watch": "npm run build:esm-cjs -- --watch",
30
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
31
+ "clean": "npm run clean:size && rimraf lib-esm lib dist",
32
+ "clean:size": "rimraf dual-publish-tmp tmp*",
33
+ "format": "echo \"Not implemented\"",
34
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
35
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
36
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
37
+ },
38
+ "typesVersions": {
39
+ ">=4.2": {
40
+ "s3": [
41
+ "./dist/esm/providers/s3/index.d.ts"
42
+ ],
43
+ "server": [
44
+ "./dist/esm/server.d.ts"
45
+ ],
46
+ "s3/server": [
47
+ "./dist/esm/providers/s3/server.d.ts"
48
+ ]
49
+ }
50
+ },
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://github.com/aws-amplify/amplify-js.git"
54
+ },
55
+ "author": "Amazon Web Services",
56
+ "license": "Apache-2.0",
57
+ "bugs": {
58
+ "url": "https://github.com/aws/aws-amplify/issues"
59
+ },
60
+ "homepage": "https://aws-amplify.github.io/",
61
+ "files": [
62
+ "dist/cjs",
63
+ "dist/esm",
64
+ "src",
65
+ "server",
66
+ "s3"
67
+ ],
68
+ "dependencies": {
69
+ "@aws-sdk/types": "3.398.0",
70
+ "@smithy/md5-js": "2.0.7",
71
+ "buffer": "4.9.2",
72
+ "fast-xml-parser": "^4.4.1",
73
+ "tslib": "^2.5.0"
74
+ },
75
+ "exports": {
76
+ ".": {
77
+ "types": "./dist/esm/index.d.ts",
78
+ "import": "./dist/esm/index.mjs",
79
+ "require": "./dist/cjs/index.js",
80
+ "react-native": "./src/index.ts"
81
+ },
82
+ "./server": {
83
+ "types": "./dist/esm/server.d.ts",
84
+ "import": "./dist/esm/server.mjs",
85
+ "require": "./dist/cjs/server.js"
86
+ },
87
+ "./s3": {
88
+ "types": "./dist/esm/providers/s3/index.d.ts",
89
+ "import": "./dist/esm/providers/s3/index.mjs",
90
+ "require": "./dist/cjs/providers/s3/index.js",
91
+ "react-native": "./src/providers/s3/index.ts"
92
+ },
93
+ "./s3/server": {
94
+ "types": "./dist/esm/providers/s3/server.d.ts",
95
+ "import": "./dist/esm/providers/s3/server.mjs",
96
+ "require": "./dist/cjs/providers/s3/server.js"
97
+ },
98
+ "./package.json": "./package.json"
99
+ },
100
+ "peerDependencies": {
101
+ "@aws-amplify/core": "6.3.9-unstable.d7522e4.0+d7522e4"
102
+ },
103
+ "devDependencies": {
104
+ "@aws-amplify/core": "6.3.9-unstable.d7522e4.0+d7522e4",
105
+ "@aws-amplify/react-native": "1.1.5-unstable.d7522e4.0+d7522e4",
106
+ "typescript": "5.0.2"
107
+ },
108
+ "gitHead": "d7522e4f3a1c73cfeb58d075ffd33afa8466299e"
109
109
  }
@@ -22,6 +22,7 @@ import {
22
22
  MAX_URL_EXPIRATION,
23
23
  STORAGE_INPUT_KEY,
24
24
  } from '../../utils/constants';
25
+ import { constructContentDisposition } from '../../utils/constructContentDisposition';
25
26
 
26
27
  import { getProperties } from './getProperties';
27
28
 
@@ -74,6 +75,14 @@ export const getUrl = async (
74
75
  {
75
76
  Bucket: bucket,
76
77
  Key: finalKey,
78
+ ...(getUrlOptions?.contentDisposition && {
79
+ ResponseContentDisposition: constructContentDisposition(
80
+ getUrlOptions.contentDisposition,
81
+ ),
82
+ }),
83
+ ...(getUrlOptions?.contentType && {
84
+ ResponseContentType: getUrlOptions.contentType,
85
+ }),
77
86
  },
78
87
  ),
79
88
  expiresAt: new Date(Date.now() + urlExpirationInSec * 1000),
@@ -3,10 +3,11 @@
3
3
 
4
4
  import { StorageAccessLevel } from '@aws-amplify/core';
5
5
 
6
- import { ResolvedS3Config } from '../../../types/options';
6
+ import { ContentDisposition, ResolvedS3Config } from '../../../types/options';
7
7
  import { StorageUploadDataPayload } from '../../../../../types';
8
8
  import { Part, createMultipartUpload } from '../../../utils/client';
9
9
  import { logger } from '../../../../../utils';
10
+ import { constructContentDisposition } from '../../../utils/constructContentDisposition';
10
11
 
11
12
  import {
12
13
  cacheMultipartUpload,
@@ -22,7 +23,7 @@ interface LoadOrCreateMultipartUploadOptions {
22
23
  keyPrefix?: string;
23
24
  key: string;
24
25
  contentType?: string;
25
- contentDisposition?: string;
26
+ contentDisposition?: string | ContentDisposition;
26
27
  contentEncoding?: string;
27
28
  metadata?: Record<string, string>;
28
29
  size?: number;
@@ -102,7 +103,7 @@ export const loadOrCreateMultipartUpload = async ({
102
103
  Bucket: bucket,
103
104
  Key: finalKey,
104
105
  ContentType: contentType,
105
- ContentDisposition: contentDisposition,
106
+ ContentDisposition: constructContentDisposition(contentDisposition),
106
107
  ContentEncoding: contentEncoding,
107
108
  Metadata: metadata,
108
109
  },
@@ -14,6 +14,7 @@ import { ItemWithKey, ItemWithPath } from '../../types/outputs';
14
14
  import { putObject } from '../../utils/client';
15
15
  import { getStorageUserAgentValue } from '../../utils/userAgent';
16
16
  import { STORAGE_INPUT_KEY } from '../../utils/constants';
17
+ import { constructContentDisposition } from '../../utils/constructContentDisposition';
17
18
 
18
19
  /**
19
20
  * Get a function the returns a promise to call putObject API to S3.
@@ -57,7 +58,7 @@ export const putObjectJob =
57
58
  Key: finalKey,
58
59
  Body: data,
59
60
  ContentType: contentType,
60
- ContentDisposition: contentDisposition,
61
+ ContentDisposition: constructContentDisposition(contentDisposition),
61
62
  ContentEncoding: contentEncoding,
62
63
  Metadata: metadata,
63
64
  ContentMD5: isObjectLockEnabled
@@ -19,6 +19,15 @@ interface CommonOptions {
19
19
  useAccelerateEndpoint?: boolean;
20
20
  }
21
21
 
22
+ /**
23
+ * Represents the content disposition of a file.
24
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
25
+ */
26
+ export interface ContentDisposition {
27
+ type: 'attachment' | 'inline';
28
+ filename?: string;
29
+ }
30
+
22
31
  /** @deprecated This may be removed in the next major version. */
23
32
  type ReadOptions =
24
33
  | {
@@ -119,6 +128,19 @@ export type GetUrlOptions = CommonOptions & {
119
128
  * @default 900 (15 minutes)
120
129
  */
121
130
  expiresIn?: number;
131
+ /**
132
+ * The default content-disposition header value of the file when downloading it.
133
+ * If a string is provided, it will be used as-is.
134
+ * If an object is provided, it will be used to construct the header value
135
+ * based on the ContentDisposition type definition.
136
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
137
+ */
138
+ contentDisposition?: ContentDisposition | string;
139
+ /**
140
+ * The content-type header value of the file when downloading it.
141
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
142
+ */
143
+ contentType?: string;
122
144
  };
123
145
 
124
146
  /** @deprecated Use {@link GetUrlOptionsWithPath} instead. */
@@ -140,9 +162,12 @@ export type UploadDataOptions = CommonOptions &
140
162
  TransferOptions & {
141
163
  /**
142
164
  * The default content-disposition header value of the file when downloading it.
165
+ * If a string is provided, it will be used as-is.
166
+ * If an object is provided, it will be used to construct the header value
167
+ * based on the ContentDisposition type definition.
143
168
  * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
144
169
  */
145
- contentDisposition?: string;
170
+ contentDisposition?: ContentDisposition | string;
146
171
  /**
147
172
  * The default content-encoding header value of the file when downloading it.
148
173
  * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
@@ -38,7 +38,11 @@ const USER_AGENT_HEADER = 'x-amz-user-agent';
38
38
 
39
39
  export type GetObjectInput = Pick<
40
40
  GetObjectCommandInput,
41
- 'Bucket' | 'Key' | 'Range'
41
+ | 'Bucket'
42
+ | 'Key'
43
+ | 'Range'
44
+ | 'ResponseContentDisposition'
45
+ | 'ResponseContentType'
42
46
  >;
43
47
 
44
48
  export type GetObjectOutput = GetObjectCommandOutput;
@@ -156,6 +160,15 @@ export const getPresignedGetObjectUrl = async (
156
160
  config.userAgentValue,
157
161
  );
158
162
  }
163
+ if (input.ResponseContentType) {
164
+ url.searchParams.append('response-content-type', input.ResponseContentType);
165
+ }
166
+ if (input.ResponseContentDisposition) {
167
+ url.searchParams.append(
168
+ 'response-content-disposition',
169
+ input.ResponseContentDisposition,
170
+ );
171
+ }
159
172
 
160
173
  for (const [headerName, value] of Object.entries(headers).sort(
161
174
  ([key1], [key2]) => key1.localeCompare(key2),
@@ -0,0 +1,16 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ContentDisposition } from '../types/options';
5
+
6
+ export const constructContentDisposition = (
7
+ contentDisposition?: string | ContentDisposition,
8
+ ): string | undefined => {
9
+ if (!contentDisposition) return undefined;
10
+
11
+ if (typeof contentDisposition === 'string') return contentDisposition;
12
+
13
+ const { type, filename } = contentDisposition;
14
+
15
+ return filename !== undefined ? `${type}; filename="${filename}"` : type;
16
+ };