Apache Libcloud - Python
Learn how to configure Apache Libcloud for use with Filebase.
What is Apache Libcloud?
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
from libcloud.storage.base import StorageDriver
FILE_PATH = '/path/to/file/to/upload'
cls = get_driver(Provider.S3)
driver = cls('your_filebase_access_key', 'your_filebase_secret_key',host='s3.filebase.com')
container = driver.get_container(container_name='libcloud')
extra = {'meta_data': {'datafield_1': 'field_1', 'datafield_2': 'field_2'}}
with open(FILE_PATH, 'rb') as iterator:
obj = driver.upload_object_via_stream(iterator=iterator,
container=container,
object_name='backup.tar.gz',
extra=extra)Last updated