文档说明了创建容器,但没有关于如何下载和上传文件的API进行过说明,单个文件不是一堆文件。我要寻找的语言是Python3。
答案 0 :(得分: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