【问题标题】:Multipart upload with urllib3 - value error使用 urllib3 进行分段上传 - 值错误
【发布时间】:2020-09-03 14:15:04
【问题描述】:

我正在编写一个脚本来将一个大文件 (50GB) 上传到我们使用 minio 的工作服务。

config = TransferConfig(multipart_threshold=1024 * 100 * 1024, max_concurrency=10,
                        multipart_chunksize=1024 * 100 * 1024, use_threads=True)

session = boto3.Session(
    aws_access_key_id=upload_data['access_key_id'],
    aws_secret_access_key=upload_data['secret_access_key'],
    aws_session_token=upload_data['session_token'],
    region_name=upload_data['region']
)

client = session.client('s3', endpoint_url='https://maurice-storage.vdoo.team/', verify=False)
client.upload_file(
    image_file,
    upload_data['bucket'],
    upload_data['key'],
    ExtraArgs={'Metadata': {
        'name': os.path.basename(image_file),
        'size': str(os.stat(image_file).st_size),
    }},
    Config = config,
    Callback=ProgressPercentage(image_file)
)

我已将上传设置为上传 100 MB 的块(总共 500 个块),因为文件为 50GB。

但是,一旦上传达到100%,就会抛出ValueError异常:

File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\response.py", line 696, in _update_chunk_length
self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

知道为什么会发生 - 它尝试使用空的二进制值 (b'') 调用 int,但我不确定为什么会出现该值。

知道为什么会发生这种情况吗?

【问题讨论】:

    标签: python urllib3 minio


    【解决方案1】:

    看起来像服务器的问题,在广告 chunked encoding 并发送所有块之后,它没有发送最终的零长度块以指示分块响应的结束。

    更多信息here,尤其是comment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-01
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多