Backblaze B2 Storage Driver Documentation¶
Backblaze is an online backup tool that allows Windows and Mac OS X users to back up their data to an offsite data center.
Backblaze B2 is their cloud object storage offering similar to Amazon S3 and other object storage services.
Keep in mind that the service is currently in public beta and only users who have signed up and received beta access can use it. To sign up for the beta access, visit their website mentioned above.
Instantiating a driver¶
To instantiate the driver you need to pass your account id and application key to the driver constructor as shown below.
To access the account id, once we have admitted you into the beta you can login to https://secure.backblaze.com/user_signin.htm, then click “buckets” and “show account id and application key”.
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
account_id = 'XXXXXX'
application_key = 'YYYYYY'
cls = get_driver(Provider.BACKBLAZE_B2)
driver = cls(account_id, application_key)
API Docs¶
-
class
libcloud.storage.drivers.backblaze_b2.
BackblazeB2StorageDriver
(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]¶ Parameters: - key (
str
) – API key or username to be used (required) - secret (
str
) – Secret password to be used (required) - secure (
bool
) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default. - host (
str
) – Override hostname used for connections. - port (
int
) – Override port used for connections. - api_version (
str
) – Optional API version. Only used by drivers which support multiple API versions. - region (
str
) – Optional driver region. Only used by drivers which support multiple regions.
Return type: None
-
connectionCls
¶ alias of
BackblazeB2Connection
-
create_container
(container_name, ex_type='allPrivate')[source]¶ Create a new container.
Parameters: container_name ( str
) – Container name.Returns: Container instance on success. Return type: Container
-
delete_container
(container)[source]¶ Delete a container.
Parameters: container ( Container
) – Container instanceReturns: True
on success,False
otherwise.Return type: bool
-
delete_object
(obj)[source]¶ Delete an object.
Parameters: obj ( Object
) – Object instance.Returns: bool
True on success.Return type: bool
-
download_object
(obj, destination_path, overwrite_existing=False, delete_on_failure=True)[source]¶ Download an object to the specified destination path.
Parameters: - obj (
Object
) – Object instance. - destination_path (
str
) – Full path to a file or a directory where the incoming file will be saved. - overwrite_existing (
bool
) – True to overwrite an existing file, defaults to False. - delete_on_failure (
bool
) – True to delete a partially downloaded file if the download was not successful (hash mismatch / file size).
Returns: True if an object has been successfully downloaded, False otherwise.
Return type: bool
- obj (
-
download_object_as_stream
(obj, chunk_size=None)[source]¶ Return a generator which yields object data.
Parameters: - obj (
Object
) – Object instance - chunk_size (
int
) – Optional chunk size (in bytes).
- obj (
-
enable_container_cdn
(container)¶ Enable container CDN.
Parameters: container ( Container
) – Container instanceReturn type: bool
-
enable_object_cdn
(obj)¶ Enable object CDN.
Parameters: obj ( Object
) – Object instanceReturn type: bool
-
ex_get_upload_data
(container_id)[source]¶ Retrieve information used for uploading files (upload url, auth token, etc).
Rype: dict
-
get_container
(container_name)[source]¶ Return a container instance.
Parameters: container_name ( str
) – Container name.Returns: Container
instance.Return type: Container
-
get_container_cdn_url
(container)¶ Return a container CDN URL.
Parameters: container ( Container
) – Container instanceReturns: A CDN URL for this container. Return type: str
-
get_object
(container_name, object_name)[source]¶ Return an object instance.
Parameters: - container_name (
str
) – Container name. - object_name (
str
) – Object name.
Returns: Object
instance.Return type: Object
- container_name (
-
get_object_cdn_url
(obj)¶ Return an object CDN URL.
Parameters: obj ( Object
) – Object instanceReturns: A CDN URL for this object. Return type: str
-
iterate_container_objects
(container)[source]¶ Return a generator of objects for the given container.
Parameters: container ( Container
) – Container instanceReturns: A generator of Object instances. Return type: generator
ofObject
-
iterate_containers
()[source]¶ Return a generator of containers for the given account
Returns: A generator of Container instances. Return type: generator
ofContainer
-
list_container_objects
(container, ex_prefix=None)¶ Return a list of objects for the given container.
Parameters: - container (
Container
) – Container instance. - ex_prefix (
str
) – Filter objects starting with a prefix.
Returns: A list of Object instances.
Return type: list
ofObject
- container (
-
list_containers
()¶ Return a list of containers.
Returns: A list of Container instances. Return type: list
ofContainer
- key (