Apache Libcloud - Python
Learn how to configure Apache Libcloud for use with Filebase.

What is Apache Libcloud?

Apache Libcloud is a Python package that allows you to manage cloud resources through an easy to use API within your Python program.
Read below to learn how to use Apache Libcloud with Filebase.

Prerequisites:

  • Download and install Apache Libcloud
  • Have your Filebase Access and Secret Keys. Learn how to view your access keys here.
  • Create a Filebase Bucket. Learn how to create a bucket here.
Use the following Python code to connect the Apache Libcloud connector to Filebase:
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)
If you have any questions, please join our Discord server, or send us an email at [email protected]
Copy link