简体   繁体   English

Boto3 Copy_Object 大小 > 5GB 失败

[英]Boto3 Copy_Object failing on size > 5GB

I have the following function我有以下功能

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')

This works great if the file is under 5gb, but fails if the object is over 5gb.如果文件小于 5gb,这很有效,但如果对象超过 5gb,则失败。

I get the following error:我收到以下错误:

An error occurred (InvalidRequest) when calling the CopyObject operation: The specified copy source is larger than the maximum allowable size for a copy source: 5368709120: 1313调用 CopyObject 操作时发生错误(InvalidRequest):指定的复制源大于复制源的最大允许大小:5368709120:1313

Is there a work around for this?有解决办法吗?

You need to use the boto3 copy method instead of copy_object .您需要使用 boto3 copy方法而不是copy_object It will perform the multi-part upload that is required when copying objects greater than 5GB.它将执行复制大于 5GB 的对象时所需的分段上传。 It will also handle the threading for you.它还将为您处理线程。

You should consider using Multipart uploads.In a single operation, maximum allowed size is 5GB您应该考虑使用分段上传。在单个操作中,最大允许大小为 5GB

Multi-part upload 分段上传

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

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