简体   繁体   English

boto3 s3 copy_object 与 ContentEncoding 参数

[英]boto3 s3 copy_object with ContentEncoding argument

I'm trying to copy s3 object with boto3 command like below我正在尝试使用如下所示的 boto3 命令复制 s3 对象

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.复制对象成功,但ContentEncoding元数据未添加到对象。

When I use the console to add Content-Encoding metadata, there was no problem.当我使用控制台添加 Content-Encoding 元数据时,没有问题。

But using python boto3 copy command, it cannot do that.但是使用 python boto3 copy 命令,它不能这样做。

Here's a document link about client.copy_object()这是关于client.copy_object()的文档链接

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.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蟒蛇=2.7.16

boto3=1.0.28 boto3=1.0.28

botocore=1.13.50 botocore=1.13.50

Thank you in advance.先感谢您。

尝试将 MetadataDirective='REPLACE' 添加到您的 copy_object 调用

client.copy_object(Bucket=bucket_name, ContentEncoding='gzip', CopySource=copy_source, Key=new_key, MetadataDirective='REPLACE')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM