Boto3 Copy_Object 大小 > 5GB 时失败

问题描述 投票:0回答:3

我有以下功能

async def _s3_copy_object(self, s3_source, s3_destination):
        source_bucket, source_key = get_s3_bucket_and_key(s3_source)
        destination_bucket, destination_key = get_s3_bucket_and_key(s3_destination)
    
        print("copying object: {} to {}".format(s3_source, s3_destination))
        source = {'Bucket': source_bucket, 'Key': source_key}
        await self._async_s3.copy_object(CopySource=source,
                                         Bucket=destination_bucket, Key=destination_key,
                                         ServerSideEncryption='AES256',
                                         MetadataDirective='COPY',
                                         TaggingDirective='COPY')

如果文件小于 5GB,这非常有效,但如果对象超过 5GB,则失败。

我收到以下错误:

调用CopyObject操作时发生错误(InvalidRequest):指定的复制源大于复制源允许的最大大小:5368709120:1313

有解决办法吗?

python amazon-web-services amazon-s3 boto3
3个回答
19
投票

您需要使用 boto3

copy
方法而不是
copy_object
。复制大于 5GB 的对象时,它将执行所需的分段上传。它还将为您处理线程。


0
投票

您应该考虑使用分段上传。在单次操作中,允许的最大大小为 5GB

分块上传


0
投票

导入子流程

命令=“aws s3 mv”

subprocess.call(命令,shell=True)

CLI 自动为您执行分段上传。您可以在命令中添加所需的任何参数。

© www.soinside.com 2019 - 2024. All rights reserved.