0

The documentation states creating containers but no API has been explained as to how one can download and upload a file, single file not a bunch of them. The language I am looking for is Python3.

aviral sanjay
  • 953
  • 2
  • 14
  • 31

1 Answers1

0

You can try this code which works for me to upload to 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)

source: https://libcloud.readthedocs.io/en/latest/storage/examples.html

Shakeel
  • 1,869
  • 15
  • 23