【发布时间】: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,但我不确定为什么会出现该值。
知道为什么会发生这种情况吗?
【问题讨论】: