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.


Instantiating a driver

To instantiate the driver you need to pass your key id and application key to the driver constructor as shown below.

To access the credentials, you can login to, then click “App Keys” or go to directly.

keyID serves as the first and applicationKey as the second argument to the driver constructor.

from import Provider
from import get_driver

key_id = 'XXXXXX'
application_key = 'YYYYYY'

cls = get_driver(Provider.BACKBLAZE_B2)
driver = cls(key_id, application_key)

API Docs

class, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]
  • 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:



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 a container.

Parameters:container (Container) – Container instance
Returns:True on success, False otherwise.
Return type:bool

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.

  • 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).

True if an object has been successfully downloaded, False otherwise.

Return type:


download_object_as_stream(obj, chunk_size=None)[source]

Return a generator which yields object data.

  • obj (Object) – Object instance
  • chunk_size (int) – Optional chunk size (in bytes).

Enable container CDN.

Parameters:container (Container) – Container instance
Return type:bool

Enable object CDN.

Parameters:obj (Object) – Object instance
Return type:bool

Retrieve information used for uploading files (upload url, auth token, etc).


Retrieve URL used for file uploads.

Return type:str

Return a container instance.

Parameters:container_name (str) – Container name.
Returns:Container instance.
Return type:Container

Return a container CDN URL.

Parameters:container (Container) – Container instance
Returns:A CDN URL for this container.
Return type:str
get_object(container_name, object_name)[source]

Return an object instance.

  • container_name (str) – Container name.
  • object_name (str) – Object name.

Object instance.

Return type:



Return an object CDN URL.

Parameters:obj (Object) – Object instance
Returns:A CDN URL for this object.
Return type:str

Return a generator of objects for the given container.

Parameters:container (Container) – Container instance
Returns:A generator of Object instances.
Return type:generator of Object

Return a generator of containers for the given account

Returns:A generator of Container instances.
Return type:generator of Container
list_container_objects(container, ex_prefix=None)

Return a list of objects for the given container.

  • container (Container) – Container instance.
  • ex_prefix (str) – Filter objects starting with a prefix.

A list of Object instances.

Return type:

list of Object


Return a list of containers.

Returns:A list of Container instances.
Return type:list of Container
upload_object(file_path, container, object_name, extra=None, verify_hash=True, headers=None)[source]

Upload an object.

Note: This will override file with a same name if it already exists.

upload_object_via_stream(iterator, container, object_name, extra=None, headers=None)[source]

Upload an object.

Note: Backblaze does not yet support uploading via stream, so this calls upload_object internally requiring the object data to be loaded into memory at once