1

I am copying objects between two s3 buckets. As a part copy process i am renaming the file, is there a way to capture the Object "key" response from destination after a copy succeeds

Reference:how to copy s3 object from one bucket to another using python boto3

s3_resource.meta.client.copy(copy_source, destination_bucket, modified_filename)

codeexplorer
  • 409
  • 1
  • 6
  • 19

1 Answers1

0

The only way that I know of doing this is to make a call to list the objects in the target bucket and make sure that your file modified_filename is in the keys. Something like this should work (assuming you have only one profile in your ~/.aws/config or ~/.aws/credentials file:

s3_client = boto3.client('s3')

for obj in s3_client.list_objects(Bucket=destination_bucket)['Contents']:
    if modified_filename in obj['Key']:
        successful_copy = True
eatsfood
  • 950
  • 2
  • 21
  • 31