文档说明创建容器,但没有解释如何下载和上传文件的 API,单个文件而不是一堆文件。我正在寻找的语言是 Python3。
问问题
224 次
1 回答
0
您可以尝试使用此代码上传到 S3。
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
FILE_PATH = 'test.txt'
cls = get_driver(Provider.S3)
driver = cls('api key', 'api secret key')
container = driver.get_container(container_name='testing-bucket')
extra = {'meta_data': {'owner': 'shakeel', 'created': '2014-02-2'}}
with open(FILE_PATH, 'rb') as iterator:
obj = driver.upload_object_via_stream(iterator=iterator,
container=container,
object_name='test.txt',
extra=extra)
来源:https ://libcloud.readthedocs.io/en/latest/storage/examples.html
于 2019-01-31T11:46:07.857 回答