Skip to content

Commit 6e5b3c5

Browse files
committed
feat(storage): resolve merge issue with multibucket
1 parent 0712035 commit 6e5b3c5

File tree

1 file changed

+19
-10
lines changed
  • packages/storage/src/providers/s3/apis/internal

1 file changed

+19
-10
lines changed

packages/storage/src/providers/s3/apis/internal/copy.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,27 @@ const copyWithPath = async (
5656
input: CopyWithPathInput,
5757
): Promise<CopyWithPathOutput> => {
5858
const { source, destination } = input;
59-
// TODO(@AllanZhengYP)
60-
await resolveS3ConfigAndInput(amplify, input);
6159

6260
storageBucketAssertion(source.bucket, destination.bucket);
6361

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+
});
6866

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.
7380

7481
assertValidationError(!!source.path, StorageValidationErrorCode.NoSourcePath);
7582
assertValidationError(
@@ -121,6 +128,8 @@ export const copyWithKey = async (
121128
options: input.source,
122129
});
123130

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.
124133
const {
125134
s3Config,
126135
bucket: destBucket,

0 commit comments

Comments
 (0)