@aws-amplify/storage 6.9.6 → 6.9.7-unstable.3ea1c8e.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.
@@ -66,6 +66,7 @@ const copyWithPath = async (amplify, input) => {
66
66
  eTag: input.source.eTag,
67
67
  expectedSourceBucketOwner: input.source?.expectedBucketOwner,
68
68
  expectedBucketOwner: input.destination?.expectedBucketOwner,
69
+ tagConfig: input.tagConfig,
69
70
  });
70
71
  return { path: finalCopyDestination };
71
72
  };
@@ -116,7 +117,7 @@ const copyWithKey = async (amplify, input) => {
116
117
  };
117
118
  };
118
119
  exports.copyWithKey = copyWithKey;
119
- const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, }) => {
120
+ const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, tagConfig, }) => {
120
121
  await (0, s3data_1.copyObject)({
121
122
  ...s3Config,
122
123
  userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.Copy),
@@ -125,6 +126,7 @@ const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedS
125
126
  CopySource: source,
126
127
  Key: destination,
127
128
  MetadataDirective: 'COPY', // Copies over metadata like contentType as well
129
+ TaggingDirective: tagConfig?.mode === 'remove' ? 'REPLACE' : 'COPY',
128
130
  CopySourceIfMatch: eTag,
129
131
  CopySourceIfUnmodifiedSince: notModifiedSince,
130
132
  ExpectedSourceBucketOwner: expectedSourceBucketOwner,
@@ -1 +1 @@
1
- {"version":3,"file":"copy.js","sources":["../../../../../../src/providers/s3/apis/internal/copy.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.copyWithKey = exports.copy = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst s3data_1 = require(\"../../utils/client/s3data\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst isCopyInputWithPath = (input) => (0, utils_2.isInputWithPath)(input.source);\nconst storageBucketAssertion = (sourceBucket, destBucket) => {\n /** For multi-bucket, both source and destination bucket needs to be passed in\n * or both can be undefined and we fallback to singleton's default value\n */\n (0, assertValidationError_1.assertValidationError)(\n // Both src & dest bucket option is present is acceptable\n (sourceBucket !== undefined && destBucket !== undefined) ||\n // or both are undefined is also acceptable\n (!destBucket && !sourceBucket), validation_1.StorageValidationErrorCode.InvalidCopyOperationStorageBucket);\n};\nconst copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : (0, exports.copyWithKey)(amplify, input);\n};\nexports.copy = copy;\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n const { bucket: sourceBucket } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n path: input.source.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, identityId, } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n path: input.destination.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n customEndpoint: input.options?.customEndpoint,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n (0, assertValidationError_1.assertValidationError)(!!source.path, validation_1.StorageValidationErrorCode.NoSourcePath);\n (0, assertValidationError_1.assertValidationError)(!!destination.path, validation_1.StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = (0, utils_2.validateStorageOperationInput)(source, identityId);\n const { objectKey: destinationPath } = (0, utils_2.validateStorageOperationInput)(destination, identityId);\n (0, utils_2.validateBucketOwnerID)(source.expectedBucketOwner);\n (0, utils_2.validateBucketOwnerID)(destination.expectedBucketOwner);\n const finalCopySource = `${sourceBucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return { path: finalCopyDestination };\n};\n/** @deprecated Use {@link copyWithPath} instead. */\nconst copyWithKey = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n (0, assertValidationError_1.assertValidationError)(!!source.key, validation_1.StorageValidationErrorCode.NoSourceKey);\n (0, assertValidationError_1.assertValidationError)(!!destination.key, validation_1.StorageValidationErrorCode.NoDestinationKey);\n (0, utils_2.validateBucketOwnerID)(source.expectedBucketOwner);\n (0, utils_2.validateBucketOwnerID)(destination.expectedBucketOwner);\n const { bucket: sourceBucket, keyPrefix: sourceKeyPrefix } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, keyPrefix: destinationKeyPrefix, } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is \"protected\", currently it's ${srcLevel}`\n const finalCopySource = `${sourceBucket}/${sourceKeyPrefix}${source.key}`;\n const finalCopyDestination = `${destinationKeyPrefix}${destination.key}`;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return {\n key: destination.key,\n };\n};\nexports.copyWithKey = copyWithKey;\nconst serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, }) => {\n await (0, s3data_1.copyObject)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: source,\n Key: destination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n CopySourceIfMatch: eTag,\n CopySourceIfUnmodifiedSince: notModifiedSince,\n ExpectedSourceBucketOwner: expectedSourceBucketOwner,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,YAAY,GA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AAM,CAAC,IAAI;AAC/B,QAAQ,yBAAyB,EAAE,KAAK,CAAC,MAAM,EAAE,mBAAmB;AACpE,QAAQ,mBAAmB,EAAE,KAAK,CAAC,WAAW,EAAE,mBAAmB;AACnE,KAAK,CAAC;AACN,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,WAAW,CAAC,GAAG;AAC5B,KAAK;AACL,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,WAAW;AACjC,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,yBAAyB,EAAE,mBAAmB,GAAG,KAAK;AAClJ,IAAI,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE;AACnC,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,IAAI,WAAW,CAAC,wBAAwB,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7F,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,MAAM;AAC1B,QAAQ,GAAG,EAAE,WAAW;AACxB,QAAQ,iBAAiB,EAAE,MAAM;AACjC,QAAQ,iBAAiB,EAAE,IAAI;AAC/B,QAAQ,2BAA2B,EAAE,gBAAgB;AACrD,QAAQ,yBAAyB,EAAE,yBAAyB;AAC5D,QAAQ,mBAAmB,EAAE,mBAAmB;AAChD,KAAK,CAAC;AACN,CAAC;;"}
1
+ {"version":3,"file":"copy.js","sources":["../../../../../../src/providers/s3/apis/internal/copy.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.copyWithKey = exports.copy = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst utils_2 = require(\"../../utils\");\nconst validation_1 = require(\"../../../../errors/types/validation\");\nconst assertValidationError_1 = require(\"../../../../errors/utils/assertValidationError\");\nconst s3data_1 = require(\"../../utils/client/s3data\");\nconst userAgent_1 = require(\"../../utils/userAgent\");\nconst utils_3 = require(\"../../../../utils\");\nconst isCopyInputWithPath = (input) => (0, utils_2.isInputWithPath)(input.source);\nconst storageBucketAssertion = (sourceBucket, destBucket) => {\n /** For multi-bucket, both source and destination bucket needs to be passed in\n * or both can be undefined and we fallback to singleton's default value\n */\n (0, assertValidationError_1.assertValidationError)(\n // Both src & dest bucket option is present is acceptable\n (sourceBucket !== undefined && destBucket !== undefined) ||\n // or both are undefined is also acceptable\n (!destBucket && !sourceBucket), validation_1.StorageValidationErrorCode.InvalidCopyOperationStorageBucket);\n};\nconst copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : (0, exports.copyWithKey)(amplify, input);\n};\nexports.copy = copy;\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n const { bucket: sourceBucket } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n path: input.source.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, identityId, } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n path: input.destination.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n customEndpoint: input.options?.customEndpoint,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n (0, assertValidationError_1.assertValidationError)(!!source.path, validation_1.StorageValidationErrorCode.NoSourcePath);\n (0, assertValidationError_1.assertValidationError)(!!destination.path, validation_1.StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = (0, utils_2.validateStorageOperationInput)(source, identityId);\n const { objectKey: destinationPath } = (0, utils_2.validateStorageOperationInput)(destination, identityId);\n (0, utils_2.validateBucketOwnerID)(source.expectedBucketOwner);\n (0, utils_2.validateBucketOwnerID)(destination.expectedBucketOwner);\n const finalCopySource = `${sourceBucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n tagConfig: input.tagConfig,\n });\n return { path: finalCopyDestination };\n};\n/** @deprecated Use {@link copyWithPath} instead. */\nconst copyWithKey = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n (0, assertValidationError_1.assertValidationError)(!!source.key, validation_1.StorageValidationErrorCode.NoSourceKey);\n (0, assertValidationError_1.assertValidationError)(!!destination.key, validation_1.StorageValidationErrorCode.NoDestinationKey);\n (0, utils_2.validateBucketOwnerID)(source.expectedBucketOwner);\n (0, utils_2.validateBucketOwnerID)(destination.expectedBucketOwner);\n const { bucket: sourceBucket, keyPrefix: sourceKeyPrefix } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, keyPrefix: destinationKeyPrefix, } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is \"protected\", currently it's ${srcLevel}`\n const finalCopySource = `${sourceBucket}/${sourceKeyPrefix}${source.key}`;\n const finalCopyDestination = `${destinationKeyPrefix}${destination.key}`;\n utils_3.logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return {\n key: destination.key,\n };\n};\nexports.copyWithKey = copyWithKey;\nconst serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, tagConfig, }) => {\n await (0, s3data_1.copyObject)({\n ...s3Config,\n userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(utils_1.StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: source,\n Key: destination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n TaggingDirective: tagConfig?.mode === 'remove' ? 'REPLACE' : 'COPY',\n CopySourceIfMatch: eTag,\n CopySourceIfUnmodifiedSince: notModifiedSince,\n ExpectedSourceBucketOwner: expectedSourceBucketOwner,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,YAAY,GAAG,OAA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vD,QAAQ,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;AAC/B,QAAQ,yBAAyB,EAAE,KAAK,CAAC,MAAM,EAAE,mBAAmB;AACpE,QAAQ,mBAAmB,EAAE,KAAK,CAAC,WAAW,EAAE,mBAAmB;AACnE,KAAK,CAAC;AACN,IAAI,OAAO;AACX,QAAQ,GAAG,EAAE,WAAW,CAAC,GAAG;AAC5B,KAAK;AACL,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,WAAW;AACjC,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,SAAS,GAAG,KAAK;AAC7J,IAAI,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE;AACnC,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,IAAI,WAAW,CAAC,wBAAwB,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7F,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,MAAM;AAC1B,QAAQ,GAAG,EAAE,WAAW;AACxB,QAAQ,iBAAiB,EAAE,MAAM;AACjC,QAAQ,gBAAgB,EAAE,SAAS,EAAE,IAAI,KAAK,QAAQ,GAAG,SAAS,GAAG,MAAM;AAC3E,QAAQ,iBAAiB,EAAE,IAAI;AAC/B,QAAQ,2BAA2B,EAAE,gBAAgB;AACrD,QAAQ,yBAAyB,EAAE,yBAAyB;AAC5D,QAAQ,mBAAmB,EAAE,mBAAmB;AAChD,KAAK,CAAC;AACN,CAAC;;"}
@@ -17,6 +17,7 @@ const copyObjectSerializer = async (input, endpoint) => {
17
17
  ...(0, utils_2.assignStringVariables)({
18
18
  'x-amz-copy-source': input.CopySource,
19
19
  'x-amz-metadata-directive': input.MetadataDirective,
20
+ 'x-amz-tagging-directive': input.TaggingDirective,
20
21
  'x-amz-copy-source-if-match': input.CopySourceIfMatch,
21
22
  'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),
22
23
  'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,
@@ -45,6 +46,7 @@ const validateCopyObjectHeaders = (input, headers) => {
45
46
  const validations = [
46
47
  headers['x-amz-copy-source'] === input.CopySource,
47
48
  (0, utils_2.bothNilOrEqual)(input.MetadataDirective, headers['x-amz-metadata-directive']),
49
+ (0, utils_2.bothNilOrEqual)(input.TaggingDirective, headers['x-amz-tagging-directive']),
48
50
  (0, utils_2.bothNilOrEqual)(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),
49
51
  (0, utils_2.bothNilOrEqual)(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),
50
52
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"copyObject.js","sources":["../../../../../../../src/providers/s3/utils/client/s3data/copyObject.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.copyObject = exports.validateCopyObjectHeaders = 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 utils_2 = require(\"../utils\");\nconst IntegrityError_1 = require(\"../../../../../errors/IntegrityError\");\nconst validateObjectUrl_1 = require(\"../../validateObjectUrl\");\nconst base_1 = require(\"./base\");\nconst copyObjectSerializer = async (input, endpoint) => {\n const headers = {\n ...(await (0, utils_2.serializeObjectConfigsToHeaders)(input)),\n ...(0, utils_2.assignStringVariables)({\n 'x-amz-copy-source': input.CopySource,\n 'x-amz-metadata-directive': input.MetadataDirective,\n 'x-amz-copy-source-if-match': input.CopySourceIfMatch,\n 'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),\n 'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,\n 'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,\n }),\n };\n (0, exports.validateCopyObjectHeaders)(input, headers);\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 url.search = new utils_1.AmplifyUrlSearchParams({\n 'x-id': 'CopyObject',\n }).toString();\n (0, validateObjectUrl_1.validateObjectUrl)({\n bucketName: input.Bucket,\n key: input.Key,\n objectURL: url,\n });\n return {\n method: 'PUT',\n headers,\n url,\n };\n};\nconst validateCopyObjectHeaders = (input, headers) => {\n const validations = [\n headers['x-amz-copy-source'] === input.CopySource,\n (0, utils_2.bothNilOrEqual)(input.MetadataDirective, headers['x-amz-metadata-directive']),\n (0, utils_2.bothNilOrEqual)(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),\n (0, utils_2.bothNilOrEqual)(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),\n ];\n if (validations.some(validation => !validation)) {\n throw new IntegrityError_1.IntegrityError();\n }\n};\nexports.validateCopyObjectHeaders = validateCopyObjectHeaders;\nconst copyObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n // error is always set when statusCode >= 300\n throw (0, utils_2.buildStorageServiceError)((await (0, base_1.parseXmlError)(response)));\n }\n else {\n await (0, utils_2.parseXmlBody)(response);\n return {\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n };\n }\n};\nexports.copyObject = (0, composers_1.composeServiceApi)(utils_2.s3TransferHandler, copyObjectSerializer, copyObjectDeserializer, { ...base_1.defaultConfig, responseType: 'text' });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,E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yBAAyB;AAC7D,MAAM,sBAAsB,GAAG,OAAO,QAAQ,KAAK;AACnD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC;AACA,QAAQ,MAAM,IAAI,OAAO,CAAC,wBAAwB,GAAG,MAAM,IAAI,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE;AAChG,IAAI;AACJ,SAAS;AACT,QAAQ,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC;AACjD,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,IAAI,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;AACtE,SAAS;AACT,IAAI;AACJ,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,IAAI,WAAW,CAAC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;;"}
1
+ {"version":3,"file":"copyObject.js","sources":["../../../../../../../src/providers/s3/utils/client/s3data/copyObject.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.copyObject = exports.validateCopyObjectHeaders = 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 utils_2 = require(\"../utils\");\nconst IntegrityError_1 = require(\"../../../../../errors/IntegrityError\");\nconst validateObjectUrl_1 = require(\"../../validateObjectUrl\");\nconst base_1 = require(\"./base\");\nconst copyObjectSerializer = async (input, endpoint) => {\n const headers = {\n ...(await (0, utils_2.serializeObjectConfigsToHeaders)(input)),\n ...(0, utils_2.assignStringVariables)({\n 'x-amz-copy-source': input.CopySource,\n 'x-amz-metadata-directive': input.MetadataDirective,\n 'x-amz-tagging-directive': input.TaggingDirective,\n 'x-amz-copy-source-if-match': input.CopySourceIfMatch,\n 'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),\n 'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,\n 'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,\n }),\n };\n (0, exports.validateCopyObjectHeaders)(input, headers);\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 url.search = new utils_1.AmplifyUrlSearchParams({\n 'x-id': 'CopyObject',\n }).toString();\n (0, validateObjectUrl_1.validateObjectUrl)({\n bucketName: input.Bucket,\n key: input.Key,\n objectURL: url,\n });\n return {\n method: 'PUT',\n headers,\n url,\n };\n};\nconst validateCopyObjectHeaders = (input, headers) => {\n const validations = [\n headers['x-amz-copy-source'] === input.CopySource,\n (0, utils_2.bothNilOrEqual)(input.MetadataDirective, headers['x-amz-metadata-directive']),\n (0, utils_2.bothNilOrEqual)(input.TaggingDirective, headers['x-amz-tagging-directive']),\n (0, utils_2.bothNilOrEqual)(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),\n (0, utils_2.bothNilOrEqual)(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),\n ];\n if (validations.some(validation => !validation)) {\n throw new IntegrityError_1.IntegrityError();\n }\n};\nexports.validateCopyObjectHeaders = validateCopyObjectHeaders;\nconst copyObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n // error is always set when statusCode >= 300\n throw (0, utils_2.buildStorageServiceError)((await (0, base_1.parseXmlError)(response)));\n }\n else {\n await (0, utils_2.parseXmlBody)(response);\n return {\n $metadata: (0, aws_client_utils_1.parseMetadata)(response),\n };\n }\n};\nexports.copyObject = (0, composers_1.composeServiceApi)(ut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ACnG,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,2BAA2B,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;AACvI,KAAK;AACL,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,EAAE;AACrD,QAAQ,MAAM,IAAI,gBAAgB,CAAC,cAAc,EAAE;AACnD,IAAI;AACJ,CAAC;AACD,OAAO,CAAC,yBAAyB,GAAG,yBAAyB;AAC7D,MAAM,sBAAsB,GAAG,OAAO,QAAQ,KAAK;AACnD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC;AACA,QAAQ,MAAM,IAAI,OAAO,CAAC,wBAAwB,GAAG,MAAM,IAAI,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE;AAChG,IAAI;AACJ,SAAS;AACT,QAAQ,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC;AACjD,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,IAAI,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC;AACtE,SAAS;AACT,IAAI;AACJ,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,IAAI,WAAW,CAAC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;;"}
@@ -76,6 +76,7 @@ type ExtendInputWithAdvancedOptions<InputType, ExtendedOptionsType> = InputType
76
76
  type ExtendCopyInputWithAdvancedOptions<InputType, ExtendedOptionsType> = InputType extends StorageCopyInputWithPath ? {
77
77
  source: InputType['source'];
78
78
  destination: InputType['destination'];
79
+ tagConfig?: InputType['tagConfig'];
79
80
  options?: ExtendedOptionsType;
80
81
  } : never;
81
82
  export {};
@@ -82,6 +82,7 @@ const copyWithPath = async (amplify, input) => {
82
82
  eTag: input.source.eTag,
83
83
  expectedSourceBucketOwner: input.source?.expectedBucketOwner,
84
84
  expectedBucketOwner: input.destination?.expectedBucketOwner,
85
+ tagConfig: input.tagConfig,
85
86
  });
86
87
  return { path: finalCopyDestination };
87
88
  };
@@ -131,7 +132,7 @@ const copyWithKey = async (amplify, input) => {
131
132
  key: destination.key,
132
133
  };
133
134
  };
134
- const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, }) => {
135
+ const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, tagConfig, }) => {
135
136
  await copyObject({
136
137
  ...s3Config,
137
138
  userAgentValue: getStorageUserAgentValue(StorageAction.Copy),
@@ -140,6 +141,7 @@ const serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedS
140
141
  CopySource: source,
141
142
  Key: destination,
142
143
  MetadataDirective: 'COPY', // Copies over metadata like contentType as well
144
+ TaggingDirective: tagConfig?.mode === 'remove' ? 'REPLACE' : 'COPY',
143
145
  CopySourceIfMatch: eTag,
144
146
  CopySourceIfUnmodifiedSince: notModifiedSince,
145
147
  ExpectedSourceBucketOwner: expectedSourceBucketOwner,
@@ -1 +1 @@
1
- {"version":3,"file":"copy.mjs","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { isInputWithPath, resolveS3ConfigAndInput, validateBucketOwnerID, validateStorageOperationInput, } from '../../utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { copyObject } from '../../utils/client/s3data';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nconst isCopyInputWithPath = (input) => isInputWithPath(input.source);\nconst storageBucketAssertion = (sourceBucket, destBucket) => {\n /** For multi-bucket, both source and destination bucket needs to be passed in\n * or both can be undefined and we fallback to singleton's default value\n */\n assertValidationError(\n // Both src & dest bucket option is present is acceptable\n (sourceBucket !== undefined && destBucket !== undefined) ||\n // or both are undefined is also acceptable\n (!destBucket && !sourceBucket), StorageValidationErrorCode.InvalidCopyOperationStorageBucket);\n};\nexport const copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : copyWithKey(amplify, input);\n};\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n const { bucket: sourceBucket } = await resolveS3ConfigAndInput(amplify, {\n path: input.source.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, identityId, } = await resolveS3ConfigAndInput(amplify, {\n path: input.destination.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n customEndpoint: input.options?.customEndpoint,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n assertValidationError(!!source.path, StorageValidationErrorCode.NoSourcePath);\n assertValidationError(!!destination.path, StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = validateStorageOperationInput(source, identityId);\n const { objectKey: destinationPath } = validateStorageOperationInput(destination, identityId);\n validateBucketOwnerID(source.expectedBucketOwner);\n validateBucketOwnerID(destination.expectedBucketOwner);\n const finalCopySource = `${sourceBucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return { path: finalCopyDestination };\n};\n/** @deprecated Use {@link copyWithPath} instead. */\nexport const copyWithKey = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n assertValidationError(!!source.key, StorageValidationErrorCode.NoSourceKey);\n assertValidationError(!!destination.key, StorageValidationErrorCode.NoDestinationKey);\n validateBucketOwnerID(source.expectedBucketOwner);\n validateBucketOwnerID(destination.expectedBucketOwner);\n const { bucket: sourceBucket, keyPrefix: sourceKeyPrefix } = await resolveS3ConfigAndInput(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, keyPrefix: destinationKeyPrefix, } = await resolveS3ConfigAndInput(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is \"protected\", currently it's ${srcLevel}`\n const finalCopySource = `${sourceBucket}/${sourceKeyPrefix}${source.key}`;\n const finalCopyDestination = `${destinationKeyPrefix}${destination.key}`;\n logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return {\n key: destination.key,\n };\n};\nconst serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, }) => {\n await copyObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: source,\n Key: destination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n CopySourceIfMatch: eTag,\n CopySourceIfUnmodifiedSince: notModifiedSince,\n ExpectedSourceBucketOwner: expectedSourceBucketOwner,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,mBAAmB,GAAG,CAAC,KAAK,KAAK,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC;AACpE,MAAM,sBAAsB,GAAG,CAAC,YAAY,EAAE,UAAU,KAAK;AAC7D;AACA;AACA;AACA,IAAI,qBAAqB;AACzB;AACA,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS;AAC3D;AACA,SAAS,CAAC,UAAU,IAAI,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAC,iCAAiC,CAAC;AACrG,CAAC;AACW,MAAC,IAAI,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC9C,IAAI,OAAO,mBAAmB,CAAC,KAAK;AACpC,UAAU,YAAY,CAAC,OAAO,EAAE,KAAK;AACrC,UAAU,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC;AACrC;AACA,MAAM,YAAY,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC/C,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK;AACzC,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;AAC7D,IAAI,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE;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GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,yBAAyB,EAAE,mBAAmB,GAAG,KAAK;AAClJ,IAAI,MAAM,UAAU,CAAC;AACrB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,IAAI,CAAC;AACpE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,MAAM;AAC1B,QAAQ,GAAG,EAAE,WAAW;AACxB,QAAQ,iBAAiB,EAAE,MAAM;AACjC,QAAQ,iBAAiB,EAAE,IAAI;AAC/B,QAAQ,2BAA2B,EAAE,gBAAgB;AACrD,QAAQ,yBAAyB,EAAE,yBAAyB;AAC5D,QAAQ,mBAAmB,EAAE,mBAAmB;AAChD,KAAK,CAAC;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"copy.mjs","sources":["../../../../../../src/providers/s3/apis/internal/copy.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { isInputWithPath, resolveS3ConfigAndInput, validateBucketOwnerID, validateStorageOperationInput, } from '../../utils';\nimport { StorageValidationErrorCode } from '../../../../errors/types/validation';\nimport { assertValidationError } from '../../../../errors/utils/assertValidationError';\nimport { copyObject } from '../../utils/client/s3data';\nimport { getStorageUserAgentValue } from '../../utils/userAgent';\nimport { logger } from '../../../../utils';\nconst isCopyInputWithPath = (input) => isInputWithPath(input.source);\nconst storageBucketAssertion = (sourceBucket, destBucket) => {\n /** For multi-bucket, both source and destination bucket needs to be passed in\n * or both can be undefined and we fallback to singleton's default value\n */\n assertValidationError(\n // Both src & dest bucket option is present is acceptable\n (sourceBucket !== undefined && destBucket !== undefined) ||\n // or both are undefined is also acceptable\n (!destBucket && !sourceBucket), StorageValidationErrorCode.InvalidCopyOperationStorageBucket);\n};\nexport const copy = async (amplify, input) => {\n return isCopyInputWithPath(input)\n ? copyWithPath(amplify, input)\n : copyWithKey(amplify, input);\n};\nconst copyWithPath = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n const { bucket: sourceBucket } = await resolveS3ConfigAndInput(amplify, {\n path: input.source.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, identityId, } = await resolveS3ConfigAndInput(amplify, {\n path: input.destination.path,\n options: {\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n customEndpoint: input.options?.customEndpoint,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n assertValidationError(!!source.path, StorageValidationErrorCode.NoSourcePath);\n assertValidationError(!!destination.path, StorageValidationErrorCode.NoDestinationPath);\n const { objectKey: sourcePath } = validateStorageOperationInput(source, identityId);\n const { objectKey: destinationPath } = validateStorageOperationInput(destination, identityId);\n validateBucketOwnerID(source.expectedBucketOwner);\n validateBucketOwnerID(destination.expectedBucketOwner);\n const finalCopySource = `${sourceBucket}/${sourcePath}`;\n const finalCopyDestination = destinationPath;\n logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n tagConfig: input.tagConfig,\n });\n return { path: finalCopyDestination };\n};\n/** @deprecated Use {@link copyWithPath} instead. */\nexport const copyWithKey = async (amplify, input) => {\n const { source, destination } = input;\n storageBucketAssertion(source.bucket, destination.bucket);\n assertValidationError(!!source.key, StorageValidationErrorCode.NoSourceKey);\n assertValidationError(!!destination.key, StorageValidationErrorCode.NoDestinationKey);\n validateBucketOwnerID(source.expectedBucketOwner);\n validateBucketOwnerID(destination.expectedBucketOwner);\n const { bucket: sourceBucket, keyPrefix: sourceKeyPrefix } = await resolveS3ConfigAndInput(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.source,\n },\n });\n // The bucket, region, credentials of s3 client are resolved from destination.\n // Whereas the source bucket and path are a input parameter of S3 copy operation.\n const { s3Config, bucket: destBucket, keyPrefix: destinationKeyPrefix, } = await resolveS3ConfigAndInput(amplify, {\n ...input,\n options: {\n // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location\n // credentials provider option, resolveS3ConfigAndInput will throw validation error.\n locationCredentialsProvider: input.options?.locationCredentialsProvider,\n ...input.destination,\n },\n }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.\n // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is \"protected\", currently it's ${srcLevel}`\n const finalCopySource = `${sourceBucket}/${sourceKeyPrefix}${source.key}`;\n const finalCopyDestination = `${destinationKeyPrefix}${destination.key}`;\n logger.debug(`copying \"${finalCopySource}\" to \"${finalCopyDestination}\".`);\n await serviceCopy({\n source: finalCopySource,\n destination: finalCopyDestination,\n bucket: destBucket,\n s3Config,\n notModifiedSince: input.source.notModifiedSince,\n eTag: input.source.eTag,\n expectedSourceBucketOwner: input.source?.expectedBucketOwner,\n expectedBucketOwner: input.destination?.expectedBucketOwner,\n });\n return {\n key: destination.key,\n };\n};\nconst serviceCopy = async ({ source, destination, bucket, s3Config, notModifiedSince, eTag, expectedSourceBucketOwner, expectedBucketOwner, tagConfig, }) => {\n await copyObject({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Copy),\n }, {\n Bucket: bucket,\n CopySource: source,\n Key: destination,\n MetadataDirective: 'COPY', // Copies over metadata like contentType as well\n TaggingDirective: tagConfig?.mode === 'remove' ? 'REPLACE' : 'COPY',\n CopySourceIfMatch: eTag,\n CopySourceIfUnmodifiedSince: notModifiedSince,\n ExpectedSourceBucketOwner: expectedSourceBucketOwner,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,mBAAmB,GAAG,CAAC,KAAK,KAAK,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC;AACpE,MAAM,sBAAsB,GAAG,CAAC,YAAY,EAAE,UAAU,KAAK;AAC7D;AACA;AACA;AACA,IAAI,qBAAqB;AACzB;AACA,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS;AAC3D;AACA,SAAS,CAAC,UAAU,IAAI,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAC,iCAAiC,CAAC;AACrG,CAAC;AACW,MAAC,IAAI,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC9C,IAAI,OAAO,mBAAmB,CAAC,KAAK;AACpC,UAAU,YAAY,CAAC,OAAO,EAAE,KAAK;AACrC,UAAU,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC;AACrC;AACA,MAAM,YAAY,GAAG,OAAO,OAAO,EAAE,KAAK,KAAK;AAC/C,IAAI,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK;AACzC,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;AAC7D,IAAI,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE;AAC5E,QAAQ,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;AAC/B,QAAQ,OAAO,EAAE;AACjB,YAAY,2BAA2B,EAAE,KAAK,CAAC,OAAO,EA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,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,SAAS,GAAG,KAAK;AAC7J,IAAI,MAAM,UAAU,CAAC;AACrB,QAAQ,GAAG,QAAQ;AACnB,QAAQ,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,IAAI,CAAC;AACpE,KAAK,EAAE;AACP,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,UAAU,EAAE,MAAM;AAC1B,QAAQ,GAAG,EAAE,WAAW;AACxB,QAAQ,iBAAiB,EAAE,MAAM;AACjC,QAAQ,gBAAgB,EAAE,SAAS,EAAE,IAAI,KAAK,QAAQ,GAAG,SAAS,GAAG,MAAM;AAC3E,QAAQ,iBAAiB,EAAE,IAAI;AAC/B,QAAQ,2BAA2B,EAAE,gBAAgB;AACrD,QAAQ,yBAAyB,EAAE,yBAAyB;AAC5D,QAAQ,mBAAmB,EAAE,mBAAmB;AAChD,KAAK,CAAC;AACN,CAAC;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { Endpoint, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
2
2
  import type { CopyObjectCommandInput, CopyObjectCommandOutput } from './types';
3
- export type CopyObjectInput = Pick<CopyObjectCommandInput, 'Bucket' | 'CopySource' | 'Key' | 'MetadataDirective' | 'CacheControl' | 'ContentType' | 'ContentDisposition' | 'ContentLanguage' | 'Expires' | 'ACL' | 'Tagging' | 'Metadata' | 'CopySourceIfUnmodifiedSince' | 'CopySourceIfMatch' | 'ExpectedSourceBucketOwner' | 'ExpectedBucketOwner'>;
3
+ export type CopyObjectInput = Pick<CopyObjectCommandInput, 'Bucket' | 'CopySource' | 'Key' | 'MetadataDirective' | 'TaggingDirective' | 'CacheControl' | 'ContentType' | 'ContentDisposition' | 'ContentLanguage' | 'Expires' | 'ACL' | 'Tagging' | 'Metadata' | 'CopySourceIfUnmodifiedSince' | 'CopySourceIfMatch' | 'ExpectedSourceBucketOwner' | 'ExpectedBucketOwner'>;
4
4
  export type CopyObjectOutput = CopyObjectCommandOutput;
5
5
  export declare const validateCopyObjectHeaders: (input: CopyObjectInput, headers: Record<string, string>) => void;
6
6
  export declare const copyObject: (config: {
@@ -21,6 +21,7 @@ const copyObjectSerializer = async (input, endpoint) => {
21
21
  ...assignStringVariables({
22
22
  'x-amz-copy-source': input.CopySource,
23
23
  'x-amz-metadata-directive': input.MetadataDirective,
24
+ 'x-amz-tagging-directive': input.TaggingDirective,
24
25
  'x-amz-copy-source-if-match': input.CopySourceIfMatch,
25
26
  'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),
26
27
  'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,
@@ -49,6 +50,7 @@ const validateCopyObjectHeaders = (input, headers) => {
49
50
  const validations = [
50
51
  headers['x-amz-copy-source'] === input.CopySource,
51
52
  bothNilOrEqual(input.MetadataDirective, headers['x-amz-metadata-directive']),
53
+ bothNilOrEqual(input.TaggingDirective, headers['x-amz-tagging-directive']),
52
54
  bothNilOrEqual(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),
53
55
  bothNilOrEqual(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),
54
56
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"copyObject.mjs","sources":["../../../../../../../src/providers/s3/utils/client/s3data/copyObject.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { assignStringVariables, bothNilOrEqual, buildStorageServiceError, parseXmlBody, s3TransferHandler, serializeObjectConfigsToHeaders, serializePathnameObjectKey, validateS3RequiredParameter, } from '../utils';\nimport { IntegrityError } from '../../../../../errors/IntegrityError';\nimport { validateObjectUrl } from '../../validateObjectUrl';\nimport { defaultConfig, parseXmlError } from './base';\nconst copyObjectSerializer = async (input, endpoint) => {\n const headers = {\n ...(await serializeObjectConfigsToHeaders(input)),\n ...assignStringVariables({\n 'x-amz-copy-source': input.CopySource,\n 'x-amz-metadata-directive': input.MetadataDirective,\n 'x-amz-copy-source-if-match': input.CopySourceIfMatch,\n 'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),\n 'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,\n 'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,\n }),\n };\n validateCopyObjectHeaders(input, headers);\n const url = new AmplifyUrl(endpoint.url.toString());\n validateS3RequiredParameter(!!input.Key, 'Key');\n url.pathname = serializePathnameObjectKey(url, input.Key);\n url.search = new AmplifyUrlSearchParams({\n 'x-id': 'CopyObject',\n }).toString();\n validateObjectUrl({\n bucketName: input.Bucket,\n key: input.Key,\n objectURL: url,\n });\n return {\n method: 'PUT',\n headers,\n url,\n };\n};\nexport const validateCopyObjectHeaders = (input, headers) => {\n const validations = [\n headers['x-amz-copy-source'] === input.CopySource,\n bothNilOrEqual(input.MetadataDirective, headers['x-amz-metadata-directive']),\n bothNilOrEqual(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),\n bothNilOrEqual(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),\n ];\n if (validations.some(validation => !validation)) {\n throw new IntegrityError();\n }\n};\nconst copyObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n // error is always set when statusCode >= 300\n throw buildStorageServiceError((await parseXmlError(response)));\n }\n else {\n await parseXmlBody(response);\n return {\n $metadata: parseMetadata(response),\n };\n }\n};\nexport const copyObject = composeServiceApi(s3TransferHandler, copyObjectSerializer, copyObjectDeserializer, { ...defaultConfig, responseType: 'text' });\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,oBAAoB,GAAG,OAAO,KAAK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D,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,CAAC,mBAAmB,CAAC,KAAK,KAAK,CAAC,UAAU;AACzD,QAAQ,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACpF,QAAQ,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACtF,QAAQ,cAAc,CAAC,KAAK,CAAC,2BAA2B,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;AAC1H,KAAK;AACL,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,EAAE;AACrD,QAAQ,MAAM,IAAI,cAAc,EAAE;AAClC,IAAI;AACJ;AACA,MAAM,sBAAsB,GAAG,OAAO,QAAQ,KAAK;AACnD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC;AACA,QAAQ,MAAM,wBAAwB,EAAE,MAAM,aAAa,CAAC,QAAQ,CAAC,EAAE;AACvE,IAAI;AACJ,SAAS;AACT,QAAQ,MAAM,YAAY,CAAC,QAAQ,CAAC;AACpC,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT,IAAI;AACJ,CAAC;AACW,MAAC,UAAU,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE;;;;"}
1
+ {"version":3,"file":"copyObject.mjs","sources":["../../../../../../../src/providers/s3/utils/client/s3data/copyObject.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { assignStringVariables, bothNilOrEqual, buildStorageServiceError, parseXmlBody, s3TransferHandler, serializeObjectConfigsToHeaders, serializePathnameObjectKey, validateS3RequiredParameter, } from '../utils';\nimport { IntegrityError } from '../../../../../errors/IntegrityError';\nimport { validateObjectUrl } from '../../validateObjectUrl';\nimport { defaultConfig, parseXmlError } from './base';\nconst copyObjectSerializer = async (input, endpoint) => {\n const headers = {\n ...(await serializeObjectConfigsToHeaders(input)),\n ...assignStringVariables({\n 'x-amz-copy-source': input.CopySource,\n 'x-amz-metadata-directive': input.MetadataDirective,\n 'x-amz-tagging-directive': input.TaggingDirective,\n 'x-amz-copy-source-if-match': input.CopySourceIfMatch,\n 'x-amz-copy-source-if-unmodified-since': input.CopySourceIfUnmodifiedSince?.toUTCString(),\n 'x-amz-source-expected-bucket-owner': input.ExpectedSourceBucketOwner,\n 'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,\n }),\n };\n validateCopyObjectHeaders(input, headers);\n const url = new AmplifyUrl(endpoint.url.toString());\n validateS3RequiredParameter(!!input.Key, 'Key');\n url.pathname = serializePathnameObjectKey(url, input.Key);\n url.search = new AmplifyUrlSearchParams({\n 'x-id': 'CopyObject',\n }).toString();\n validateObjectUrl({\n bucketName: input.Bucket,\n key: input.Key,\n objectURL: url,\n });\n return {\n method: 'PUT',\n headers,\n url,\n };\n};\nexport const validateCopyObjectHeaders = (input, headers) => {\n const validations = [\n headers['x-amz-copy-source'] === input.CopySource,\n bothNilOrEqual(input.MetadataDirective, headers['x-amz-metadata-directive']),\n bothNilOrEqual(input.TaggingDirective, headers['x-amz-tagging-directive']),\n bothNilOrEqual(input.CopySourceIfMatch, headers['x-amz-copy-source-if-match']),\n bothNilOrEqual(input.CopySourceIfUnmodifiedSince?.toUTCString(), headers['x-amz-copy-source-if-unmodified-since']),\n ];\n if (validations.some(validation => !validation)) {\n throw new IntegrityError();\n }\n};\nconst copyObjectDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n // error is always set when statusCode >= 300\n throw buildStorageServiceError((await parseXmlError(response)));\n }\n else {\n await parseXmlBody(response);\n return {\n $metadata: parseMetadata(response),\n };\n }\n};\nexport const copyObject = composeServiceApi(s3TransferHandler, copyObjectSerializer, copyObjectDeserializer, { ...defaultConfig, responseType: 'text' });\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,oBAAoB,GAAG,OAAO,KAAK,EAAE,QAAQ,KAAK;AACxD,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,IAAI,MAAM,+BAA+B,CAAC,KAAK,CAAC,CAAC;AACzD,QAAQ,GAAG,qBAAqB,CAAC;AACjC,YAAY,mBAAmB,EAAE,KAAK,CAAC,UAAU;AACjD,YAAY,0BAA0B,EAAE,KAAK,CAAC,iBAAiB;AAC/D,YAAY,yBAAyB,EAAE,KAAK,CAAC,gBAAgB;AAC7D,YAAY,4BAA4B,EAAE,KAAK,CAAC,iBAAiB;AACjE,YAAY,uCAAuC,EAAE,KAAK,CAAC,2BAA2B,EAAE,WAAW,EAAE;AACrG,YAAY,oCAAoC,EAAE,KAAK,CAAC,yBAAyB;AACjF,YAAY,6BAA6B,EAAE,KAAK,CAAC,mBAAmB;AACpE,SAAS,CAAC;AACV,KAAK;AACL,IAAI,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC;AAC7C,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvD,IAAI,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;AACnD,IAAI,GAAG,CAAC,QAAQ,GAAG,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;AAC7D,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,sBAAsB,CAAC;AAC5C,QAAQ,MAAM,EAAE,YAAY;AAC5B,KAAK,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Aa,CAAC,QAAQ,CAAC;AAC9C,SAAS;AACT,IAAI;AACJ,CAAC;AACW,MAAC,UAAU,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE;;;;"}
@@ -43,9 +43,22 @@ export interface StorageCopyInputWithKey<SourceOptions extends StorageOptions, D
43
43
  source: SourceOptions;
44
44
  destination: DestinationOptions;
45
45
  }
46
+ export interface CopyTagConfig {
47
+ mode: 'copy';
48
+ }
49
+ export interface RemoveTagConfig {
50
+ mode: 'remove';
51
+ }
52
+ export interface ReplaceTagConfig {
53
+ mode: 'replace';
54
+ tags: Record<string, string>;
55
+ }
56
+ export type TagConfigInternal = CopyTagConfig | RemoveTagConfig | ReplaceTagConfig;
57
+ export type TagConfig = Exclude<TagConfigInternal, ReplaceTagConfig>;
46
58
  export interface StorageCopyInputWithPath {
47
59
  source: StorageOperationInputWithPath & CopyWithPathSourceOptions;
48
60
  destination: StorageOperationInputWithPath & CopyWithPathDestinationOptions;
61
+ tagConfig?: TagConfig;
49
62
  }
50
63
  /**
51
64
  * The data payload type for upload operation.
package/package.json CHANGED
@@ -1,119 +1,119 @@
1
1
  {
2
- "name": "@aws-amplify/storage",
3
- "version": "6.9.6",
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
- "internals": [
44
- "./dist/esm/internals/index.d.ts"
45
- ],
46
- "server": [
47
- "./dist/esm/server.d.ts"
48
- ],
49
- "s3/server": [
50
- "./dist/esm/providers/s3/server.d.ts"
51
- ]
52
- }
53
- },
54
- "repository": {
55
- "type": "git",
56
- "url": "https://github.com/aws-amplify/amplify-js.git"
57
- },
58
- "author": "Amazon Web Services",
59
- "license": "Apache-2.0",
60
- "bugs": {
61
- "url": "https://github.com/aws/aws-amplify/issues"
62
- },
63
- "homepage": "https://aws-amplify.github.io/",
64
- "files": [
65
- "dist/cjs",
66
- "dist/esm",
67
- "internals",
68
- "src",
69
- "server",
70
- "s3"
71
- ],
72
- "dependencies": {
73
- "@aws-sdk/types": "3.398.0",
74
- "@smithy/md5-js": "2.0.7",
75
- "buffer": "4.9.2",
76
- "crc-32": "1.2.2",
77
- "fast-xml-parser": "^4.4.1",
78
- "tslib": "^2.5.0"
79
- },
80
- "exports": {
81
- ".": {
82
- "react-native": "./dist/cjs/index.js",
83
- "types": "./dist/esm/index.d.ts",
84
- "import": "./dist/esm/index.mjs",
85
- "require": "./dist/cjs/index.js"
86
- },
87
- "./internals": {
88
- "types": "./dist/esm/internals/index.d.ts",
89
- "import": "./dist/esm/internals/index.mjs",
90
- "require": "./dist/cjs/internals/index.js"
91
- },
92
- "./server": {
93
- "types": "./dist/esm/server.d.ts",
94
- "import": "./dist/esm/server.mjs",
95
- "require": "./dist/cjs/server.js"
96
- },
97
- "./s3": {
98
- "react-native": "./dist/cjs/providers/s3/index.js",
99
- "types": "./dist/esm/providers/s3/index.d.ts",
100
- "import": "./dist/esm/providers/s3/index.mjs",
101
- "require": "./dist/cjs/providers/s3/index.js"
102
- },
103
- "./s3/server": {
104
- "types": "./dist/esm/providers/s3/server.d.ts",
105
- "import": "./dist/esm/providers/s3/server.mjs",
106
- "require": "./dist/cjs/providers/s3/server.js"
107
- },
108
- "./package.json": "./package.json"
109
- },
110
- "peerDependencies": {
111
- "@aws-amplify/core": "^6.1.0"
112
- },
113
- "devDependencies": {
114
- "@aws-amplify/core": "6.13.2",
115
- "@aws-amplify/react-native": "1.1.10",
116
- "@types/node": "20.14.12"
117
- },
118
- "gitHead": "21ebe0a1e6f009a419864ed8550d20a3528d8944"
2
+ "name": "@aws-amplify/storage",
3
+ "version": "6.9.7-unstable.3ea1c8e.0+3ea1c8e",
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
+ "internals": [
44
+ "./dist/esm/internals/index.d.ts"
45
+ ],
46
+ "server": [
47
+ "./dist/esm/server.d.ts"
48
+ ],
49
+ "s3/server": [
50
+ "./dist/esm/providers/s3/server.d.ts"
51
+ ]
52
+ }
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/aws-amplify/amplify-js.git"
57
+ },
58
+ "author": "Amazon Web Services",
59
+ "license": "Apache-2.0",
60
+ "bugs": {
61
+ "url": "https://github.com/aws/aws-amplify/issues"
62
+ },
63
+ "homepage": "https://aws-amplify.github.io/",
64
+ "files": [
65
+ "dist/cjs",
66
+ "dist/esm",
67
+ "internals",
68
+ "src",
69
+ "server",
70
+ "s3"
71
+ ],
72
+ "dependencies": {
73
+ "@aws-sdk/types": "3.398.0",
74
+ "@smithy/md5-js": "2.0.7",
75
+ "buffer": "4.9.2",
76
+ "crc-32": "1.2.2",
77
+ "fast-xml-parser": "^4.4.1",
78
+ "tslib": "^2.5.0"
79
+ },
80
+ "exports": {
81
+ ".": {
82
+ "react-native": "./dist/cjs/index.js",
83
+ "types": "./dist/esm/index.d.ts",
84
+ "import": "./dist/esm/index.mjs",
85
+ "require": "./dist/cjs/index.js"
86
+ },
87
+ "./internals": {
88
+ "types": "./dist/esm/internals/index.d.ts",
89
+ "import": "./dist/esm/internals/index.mjs",
90
+ "require": "./dist/cjs/internals/index.js"
91
+ },
92
+ "./server": {
93
+ "types": "./dist/esm/server.d.ts",
94
+ "import": "./dist/esm/server.mjs",
95
+ "require": "./dist/cjs/server.js"
96
+ },
97
+ "./s3": {
98
+ "react-native": "./dist/cjs/providers/s3/index.js",
99
+ "types": "./dist/esm/providers/s3/index.d.ts",
100
+ "import": "./dist/esm/providers/s3/index.mjs",
101
+ "require": "./dist/cjs/providers/s3/index.js"
102
+ },
103
+ "./s3/server": {
104
+ "types": "./dist/esm/providers/s3/server.d.ts",
105
+ "import": "./dist/esm/providers/s3/server.mjs",
106
+ "require": "./dist/cjs/providers/s3/server.js"
107
+ },
108
+ "./package.json": "./package.json"
109
+ },
110
+ "peerDependencies": {
111
+ "@aws-amplify/core": "6.13.3-unstable.3ea1c8e.0+3ea1c8e"
112
+ },
113
+ "devDependencies": {
114
+ "@aws-amplify/core": "6.13.3-unstable.3ea1c8e.0+3ea1c8e",
115
+ "@aws-amplify/react-native": "1.1.11-unstable.3ea1c8e.0+3ea1c8e",
116
+ "@types/node": "20.14.12"
117
+ },
118
+ "gitHead": "3ea1c8e75ce9b03be24803184d912f8f2dee87ad"
119
119
  }
@@ -137,6 +137,7 @@ type ExtendCopyInputWithAdvancedOptions<InputType, ExtendedOptionsType> =
137
137
  ? {
138
138
  source: InputType['source'];
139
139
  destination: InputType['destination'];
140
+ tagConfig?: InputType['tagConfig'];
140
141
  options?: ExtendedOptionsType;
141
142
  }
142
143
  : never;
@@ -10,6 +10,7 @@ import {
10
10
  CopyWithPathInput,
11
11
  CopyWithPathOutput,
12
12
  } from '../../types';
13
+ import { TagConfig } from '../../../../types/inputs';
13
14
  import { ResolvedS3Config, StorageBucket } from '../../types/options';
14
15
  import {
15
16
  isInputWithPath,
@@ -114,6 +115,7 @@ const copyWithPath = async (
114
115
  eTag: input.source.eTag,
115
116
  expectedSourceBucketOwner: input.source?.expectedBucketOwner,
116
117
  expectedBucketOwner: input.destination?.expectedBucketOwner,
118
+ tagConfig: input.tagConfig,
117
119
  });
118
120
 
119
121
  return { path: finalCopyDestination };
@@ -193,6 +195,7 @@ const serviceCopy = async ({
193
195
  eTag,
194
196
  expectedSourceBucketOwner,
195
197
  expectedBucketOwner,
198
+ tagConfig,
196
199
  }: {
197
200
  source: string;
198
201
  destination: string;
@@ -202,6 +205,7 @@ const serviceCopy = async ({
202
205
  eTag?: string;
203
206
  expectedSourceBucketOwner?: string;
204
207
  expectedBucketOwner?: string;
208
+ tagConfig?: TagConfig;
205
209
  }) => {
206
210
  await copyObject(
207
211
  {
@@ -213,6 +217,7 @@ const serviceCopy = async ({
213
217
  CopySource: source,
214
218
  Key: destination,
215
219
  MetadataDirective: 'COPY', // Copies over metadata like contentType as well
220
+ TaggingDirective: tagConfig?.mode === 'remove' ? 'REPLACE' : 'COPY',
216
221
  CopySourceIfMatch: eTag,
217
222
  CopySourceIfUnmodifiedSince: notModifiedSince,
218
223
  ExpectedSourceBucketOwner: expectedSourceBucketOwner,
@@ -35,6 +35,7 @@ export type CopyObjectInput = Pick<
35
35
  | 'CopySource'
36
36
  | 'Key'
37
37
  | 'MetadataDirective'
38
+ | 'TaggingDirective'
38
39
  | 'CacheControl'
39
40
  | 'ContentType'
40
41
  | 'ContentDisposition'
@@ -60,6 +61,7 @@ const copyObjectSerializer = async (
60
61
  ...assignStringVariables({
61
62
  'x-amz-copy-source': input.CopySource,
62
63
  'x-amz-metadata-directive': input.MetadataDirective,
64
+ 'x-amz-tagging-directive': input.TaggingDirective,
63
65
  'x-amz-copy-source-if-match': input.CopySourceIfMatch,
64
66
  'x-amz-copy-source-if-unmodified-since':
65
67
  input.CopySourceIfUnmodifiedSince?.toUTCString(),
@@ -97,6 +99,7 @@ export const validateCopyObjectHeaders = (
97
99
  input.MetadataDirective,
98
100
  headers['x-amz-metadata-directive'],
99
101
  ),
102
+ bothNilOrEqual(input.TaggingDirective, headers['x-amz-tagging-directive']),
100
103
  bothNilOrEqual(
101
104
  input.CopySourceIfMatch,
102
105
  headers['x-amz-copy-source-if-match'],
@@ -95,9 +95,30 @@ export interface StorageCopyInputWithKey<
95
95
  destination: DestinationOptions;
96
96
  }
97
97
 
98
+ export interface CopyTagConfig {
99
+ mode: 'copy';
100
+ }
101
+
102
+ export interface RemoveTagConfig {
103
+ mode: 'remove';
104
+ }
105
+
106
+ export interface ReplaceTagConfig {
107
+ mode: 'replace';
108
+ tags: Record<string, string>;
109
+ }
110
+
111
+ export type TagConfigInternal =
112
+ | CopyTagConfig
113
+ | RemoveTagConfig
114
+ | ReplaceTagConfig;
115
+
116
+ export type TagConfig = Exclude<TagConfigInternal, ReplaceTagConfig>;
117
+
98
118
  export interface StorageCopyInputWithPath {
99
119
  source: StorageOperationInputWithPath & CopyWithPathSourceOptions;
100
120
  destination: StorageOperationInputWithPath & CopyWithPathDestinationOptions;
121
+ tagConfig?: TagConfig;
101
122
  }
102
123
 
103
124
  /**