Skip to content

Basic usage documentation

BlobStorageBase

BlobStorageBase(connection_string, local_base_path='azure_tmp/')
local_base_path: local folder where data will be downloaded if path is not specified

clean_local_folder

clean_local_folder()

Empty & delete local_folder (ie. local_base_path)

create_container

create_container(container_name)

Create a container named container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required

create_local_dir classmethod

create_local_dir(directory_name)

Creates a local directory

Parameters:

Name Type Description Default
directory_name str

directory path

required

delete_blobs

delete_blobs(container_name, remote_file_names)

Delete list of blobs from container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_file_names List[str]

list of blob names

required

delete_container

delete_container(container_name)

Delete container named container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required

download_directory

download_directory(container_name, remote_directory, local_directory=None)

Download all blobs in directory

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_directory str

Name of the remote directory

required
local_directory Optional[str]

Name of the local directory where files will be downloaded

None

download_file

download_file(container_name, remote_file_name, local_file_name=None)

Download a blob named remote_file_name from a container named container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_file_name str

Name of the blob

required
local_file_name Optional[str]

Name of the local file where the blob will be downloaded

None

get_blob_client

get_blob_client(container_name, blob_name)

Get blob client from container_name & blob_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required
blob_name str

Name of the blob

required

get_container_client

get_container_client(container_name)

Get container client from container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required

get_directory_and_filename_from_full_path staticmethod

get_directory_and_filename_from_full_path(file_name)

Split file_name and get folder_name and "real" file_name

Parameters:

Name Type Description Default
file_name str required

get_file_as_bytes

get_file_as_bytes(container_name, remote_file_name)

Get blob as bytes (in memory object)

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_file_name str

Name of the blob

required

get_file_as_dict

get_file_as_dict(container_name, remote_file_name)

Get blob as dict (eg. for JSON files)

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_file_name str

Name of the blob

required

get_file_as_text

get_file_as_text(container_name, remote_file_name)

Get blob as text

Parameters:

Name Type Description Default
container_name str

Name of the container

required
remote_file_name str

Name of the blob

required

get_list_blobs_name

get_list_blobs_name(container_name, prefix=None, return_list=True)

Get list/generator of objects in container_name

Parameters:

Name Type Description Default
container_name str

Name of the container

required
prefix Optional[str]

filter blobs with prefix

None
return_list Optional[bool]

if False, returns a generator

True

upload_bytes

upload_bytes(my_bytes, container_name, remote_file_name, overwrite=False)

Uploaded in memory byte object to blob

Parameters:

Name Type Description Default
my_bytes bytes

in memory object

required
container_name str

Name of the container

required
remote_file_name str

Name of the blob where object will be uploaded

required
overwrite Optional[bool]

set to True if needed

False

upload_directory

upload_directory(container_name, local_directory_name, remote_directory_name=None, overwrite=False)

Upload local folder to blobs

Parameters:

Name Type Description Default
container_name str

Name of the container

required
local_directory_name str

Name of the local directory

required
remote_directory_name Optional[str]

Name of the remote directory where file will be uploaded

None
overwrite Optional[bool]

set to True if needed

False

upload_file

upload_file(container_name, local_file_name, remote_file_name=None, overwrite=False)

Upload a local file to a blob

Parameters:

Name Type Description Default
container_name str

Name of the container

required
local_file_name str

Name of the local file

required
remote_file_name Optional[str]

Name of the blob where file will be uploaded

None
overwrite Optional[bool]

set to True if needed

False