如何在 IBM Cloud Object Store 中上传文件时获取 Etag?

问题描述

我想在成功将对象上传到 IBM Cloud Object Store 后返回 Etag。 这是我正在使用的代码-

def upload_large_file(cos_cli,bucket_name,item_name,file_path): print("开始将 {0} 的大文件上传到存储桶:{1}".format(item_name,bucket_name))

    # set the chunk size to 5 MB
    part_size = 1024 * 1024 * 5

    # set threadhold to 5 MB
    file_threshold = 1024 * 1024 * 5


    # set the transfer threshold and chunk size in config settings
    transfer_config = ibm_boto3.s3.transfer.TransferConfig(
        multipart_threshold=file_threshold,multipart_chunksize=part_size
    )

    # create transfer manager
    transfer_mgr = ibm_boto3.s3.transfer.TransferManager(cos_cli,config=transfer_config)

    try:
        # initiate file upload
        future = transfer_mgr.upload(file_path,item_name)

        # wait for upload to complete
        future.result()

        print ("Large file upload complete!")
    except Exception as e:
        print("Unable to complete large file upload: {0}".format(e))
    finally:
        transfer_mgr.shutdown()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)