Base API
- list_containers
- list_container_object
- get_container
- get_object
- create_container
- upload_object
- upload_object_via_stream
- download_object
- download_object_as_stream
- delete_container
- delete_object
list_containers
Method signature:
driver.list_containters()
Description: Return a list of all the containers belonging to your account.
The returned object is actually an instance of LazyList
class which implements
an iterator interface and transparently handles pagination for you.
list_container_object
driver.list_container_object()
Description: Return a list of all the object inside the container.
Similar to the list_containers this method also returns a LazyList
instance.
get_container>
driver.get_container(container_name)
Description: Return a Container
instance. This method is useful if you
know the container name and want perform operations on it. Usually it is also
more efficient then calling list_containers()
and manually iterating over the
list to find the container you are interested in.
get_object
driver.get_object(container_name, object_name)
Description: Return an Object
instance. Similar to the get_container
this method is also useful if you know the name of the object and the container
holding this object and you want to perform operations on it.
create_container
driver.create_container(container_name)
Description: Create a new container.
upload_object
driver.upload_object(file_path, container, object_name, extra=None, verify_hash),
container.upload_object(file_path, object_name, extra=None, verify_hash)
Description: Upload a file stored on a disk.
upload_object_via_stream
driver.upload_object_via_stream(iterator, container, object_name, extra),
container.upload_object_via_stream(file_path, object_name, extra=None, verify_hash)
Description: Upload an object using an iterator. If a provider supports
chunked transfer encoding this method doesn't require you to know the object
size in advance. This allows you to directly stream data to the provider without
buffering it on disk.
Good example of this are backups - you can directly stream tar output to the provider without buffering or temporary storing data on the disk.
Note: If the provider doesn't support chunked transfer encoding this function will first exhaust your iterator to determine the file size and then send it to the provider. Exhausting the iterator means that the whole iterator content must be buffered in the memory which might lead to the resource exhaustion.
download_object
driver.download_object(obj, destination_path, overwrite_existing, delete_on_failure),
container.download_object(obj, destination_path, overwrite_existing, delete_on_failure),
object.download(destination_path, overwrite_existing, delete_on_failure)
Description: Download an object and save it to a file on disk.
download_object_as_stream
driver.download_object_as_stream(obj, chunk_size),
container.download_object_as_stream(obj, chunk_size),
object.as_stream(chunk_size)
Description: Return a generator which yields object data. This method is
useful if you don't want to directly save object on disk and want to perform
some other operations with it.
delete_container
driver.delete_container(container),
container.delete()
Description: Delete a container.
delete_object
driver.delete_object(obj),
container.delete_object(obj),
object.delete()
Description: Delete an object.