简体   繁体   English

使用 urllib3 分段上传 - 值错误

[英]Multipart upload with urllib3 - value error

I'm writing a script to upload a large file (50GB) to our service at work which utilizes minio.我正在编写一个脚本,将一个大文件 (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)
)

I've set the upload to upload chunks of 100 MB (total 500 chunks) as the file is 50GB.我已将上传设置为上传 100 MB 的块(总共 500 个块),因为文件为 50GB。

However, once the upload reaches 100%, a ValueError exception is thrown:但是,一旦上传达到 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''

I know why it happens - it tries to call int with an empty binary value (b''), but i'm not sure why that value is there.知道它为什么会发生——它试图用一个空的二进制值 (b'') 调用 int,但我不确定为什么会出现这个值。

Any idea why that could happen?知道为什么会发生这种情况吗?

Looks like an issue with the server where after advertising chunked encoding and sending all the chunks, it is not sending the final zero length chunk to indicate the end of the chunked response.看起来像服务器的问题,在广告分块编码并发送所有块之后,它没有发送最终的零长度块来指示分块响应的结束。

More info here and especially in this comment .更多信息在这里,尤其是在这个评论中

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

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