From 4f9f9d8e8c0d7bfa0fa9877cd46378ac94b0fb31 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Wed, 24 Jul 2024 10:43:44 -0700 Subject: [PATCH] chore: address feedbacks --- .../src/providers/s3/apis/internal/copy.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/storage/src/providers/s3/apis/internal/copy.ts b/packages/storage/src/providers/s3/apis/internal/copy.ts index a8562ac3beb..9119917efa1 100644 --- a/packages/storage/src/providers/s3/apis/internal/copy.ts +++ b/packages/storage/src/providers/s3/apis/internal/copy.ts @@ -61,7 +61,10 @@ const copyWithPath = async ( const { bucket: sourceBucket } = await resolveS3ConfigAndInput(amplify, { path: input.source.path, - options: { ...input.source }, + options: { + locationCredentialsProvider: input.options?.locationCredentialsProvider, + ...input.source, + }, }); // The bucket, region, credentials of s3 client are resolved from destination. @@ -125,7 +128,12 @@ export const copyWithKey = async ( const { bucket: sourceBucket, keyPrefix: sourceKeyPrefix } = await resolveS3ConfigAndInput(amplify, { ...input, - options: input.source, + options: { + // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location + // credentials provider option, resolveS3ConfigAndInput will throw validation error. + locationCredentialsProvider: input.options?.locationCredentialsProvider, + ...input.source, + }, }); // The bucket, region, credentials of s3 client are resolved from destination. @@ -136,7 +144,12 @@ export const copyWithKey = async ( keyPrefix: destinationKeyPrefix, } = await resolveS3ConfigAndInput(amplify, { ...input, - options: input.destination, + options: { + // @ts-expect-error: 'options' does not exist on type 'CopyInput'. In case of JS users set the location + // credentials provider option, resolveS3ConfigAndInput will throw validation error. + locationCredentialsProvider: input.options?.locationCredentialsProvider, + ...input.destination, + }, }); // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly. // TODO(ashwinkumar6) V6-logger: warn `You may copy files from another user if the source level is "protected", currently it's ${srcLevel}`