petrel-oss-python-sdk2 / tests /multipart_test.py
Weiyun1025's picture
Upload folder using huggingface_hub
2abfccb verified
raw
history blame contribute delete
No virus
444 Bytes
# 如果上传的文件过大,则需要分片上传
# put 传入的参数如果实现了 read 接口即可分片上传
# 例如 open 的返回值和 io.BytesIO 均实现了 read 接口
# 上传大文件
with open("large_file", "rb") as f:
client.put(url, f)
# 上传 Tensor
with io.BytesIO() as f:
torch.save(data, f)
f.seek(0)
client.put(url, f)
# 上传大对象
with io.BytesIO(large_bytes) as f:
client.put(url, f)