我尝试使用Python中的oci-cli
库将对象上载到Oracle Storage。当我尝试使用命令行时:
oci os object put -ns grddddaaaZZ -bn dev.bucket --name processed/2020-11 --file /path/to/my/file/image.tif
我得到的回答是:
Upload ID: 4f...78f0fdc5
Split file into 2 parts for upload.
Uploading object [------------------------------------] 0%
...
但当我尝试使用这个框架时:
try:
namespace = 'grddddaaaZZ'
bucket = 'dev.bucket'
object_path = 'processed/2020-11/image.tif'
with open('/path/to/my/file/image.tif', "rb") as image:
publish_payload = image.read()
response = object_storage.put_object(namespace, bucket, object_path, publish_payload)
except (InvalidConfig, BaseConnectTimeout, ConfigFileNotFound, ServiceError) as error:
logging.error(">>>>>>>> Something went wrong when try to list bucket {} objects. Error {}".
format(bucket, error))
上传未完成:
...
response = object_storage.put_object(namespace, bucket, object_path, publish_payload)
File ".../.venv/lib/python3.8/site-packages/oci/object_storage/object_storage_client.py", line 4113, in put_object
return self.base_client.call_api(
File ".../.venv/lib/python3.8/site-packages/oci/base_client.py", line 272, in call_api
response = self.request(request)
File ".../.venv/lib/python3.8/site-packages/oci/base_client.py", line 378, in request
raise exceptions.RequestException(e)
oci.exceptions.RequestException: ('Connection aborted.', timeout('The write operation timed out'))
我以为可能是文件大小的问题(大约是208Mb),但是在put_object
文档中说限制是5Gb。所以,我不认为这可能是问题所在。我最后的机会是使用os.system()
,但这不是我真正想要的。
第二种选择可能会遗漏什么?
2条答案
按热度按时间66bbxpm51#
您可以先尝试上传一些其他数据,看看它是否是有效负载:
或者尝试不阅读文件内容而只传递file对象:
ttygqcqt2#
上面的代码卡住了很长一段时间,直到超时结束。但实际上我可以看到文件上传正确。但这个命令卡住了足够长的时间,直到超时...任何想法?