@@ -56,20 +56,27 @@ const copyWithPath = async (
56
56
input : CopyWithPathInput ,
57
57
) : Promise < CopyWithPathOutput > => {
58
58
const { source, destination } = input ;
59
- // TODO(@AllanZhengYP)
60
- await resolveS3ConfigAndInput ( amplify , input ) ;
61
59
62
60
storageBucketAssertion ( source . bucket , destination . bucket ) ;
63
61
64
- const { bucket : sourceBucket , identityId } = await resolveS3ConfigAndInput (
65
- amplify ,
66
- input . source ,
67
- ) ;
62
+ const { bucket : sourceBucket } = await resolveS3ConfigAndInput ( amplify , {
63
+ path : input . source . path ,
64
+ options : { ... input . source } ,
65
+ } ) ;
68
66
69
- const { s3Config, bucket : destBucket } = await resolveS3ConfigAndInput (
70
- amplify ,
71
- input . destination ,
72
- ) ; // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.
67
+ // The bucket, region, credentials of s3 client are resolved from destination.
68
+ // Whereas the source bucket and path are a input parameter of S3 copy operation.
69
+ const {
70
+ s3Config,
71
+ bucket : destBucket ,
72
+ identityId,
73
+ } = await resolveS3ConfigAndInput ( amplify , {
74
+ path : input . destination . path ,
75
+ options : {
76
+ locationCredentialsProvider : input . options ?. locationCredentialsProvider ,
77
+ ...input . destination ,
78
+ } ,
79
+ } ) ; // resolveS3ConfigAndInput does not make extra API calls or storage access if called repeatedly.
73
80
74
81
assertValidationError ( ! ! source . path , StorageValidationErrorCode . NoSourcePath ) ;
75
82
assertValidationError (
@@ -121,6 +128,8 @@ export const copyWithKey = async (
121
128
options : input . source ,
122
129
} ) ;
123
130
131
+ // The bucket, region, credentials of s3 client are resolved from destination.
132
+ // Whereas the source bucket and path are a input parameter of S3 copy operation.
124
133
const {
125
134
s3Config,
126
135
bucket : destBucket ,
0 commit comments