Complete a multipart_upload with boto3?

前端 未结 6 2251
-上瘾入骨i
-上瘾入骨i 2020-12-28 21:31

Tried this:

import boto3
from boto3.s3.transfer import TransferConfig, S3Transfer
path = \"/temp/\"
fileName = \"bigFile.gz\" # this happens to be a 5.9 Gig         


        
6条回答
  •  一生所求
    2020-12-28 21:49

    I would advise you to use boto3.s3.transfer for this purpose. Here is an example:

    import boto3
    
    
    def upload_file(filename):
        session = boto3.Session()
        s3_client = session.client("s3")
    
        try:
            print("Uploading file: {}".format(filename))
    
            tc = boto3.s3.transfer.TransferConfig()
            t = boto3.s3.transfer.S3Transfer(client=s3_client, config=tc)
    
            t.upload_file(filename, "my-bucket-name", "name-in-s3.dat")
    
        except Exception as e:
            print("Error uploading: {}".format(e))
    

提交回复
热议问题