3

I'm trying to copy s3 object with boto3 command like below

import boto3 
client = boto3.client('s3')
client.copy_object(Bucket=bucket_name, ContentEncoding='gzip', CopySource=copy_source, Key=new_key)

To copy the object succeeded, but ContentEncoding metadata was not added to the object.

When I use the console to add Content-Encoding metadata, there was no problem.

But using python boto3 copy command, it cannot do that.

Here's a document link about client.copy_object()

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.copy_object

And the application versions are like this.

python=2.7.16

boto3=1.0.28

botocore=1.13.50

Thank you in advance.

Community
  • 1
  • 1

1 Answers1

3

Try adding MetadataDirective='REPLACE' to your copy_object call

client.copy_object(Bucket=bucket_name, ContentEncoding='gzip', CopySource=copy_source, Key=new_key, MetadataDirective='REPLACE')
joshua O
  • 31
  • 2