Basic usage documentation
BlobStorageBase
local_base_path: local folder where data will be downloaded if path is not specified
create_container
Create a container named container_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_name |
str
|
Name of the container |
required |
create_local_dir
classmethod
Creates a local directory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory_name |
str
|
directory path |
required |
delete_blobs
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 named container_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_name |
str
|
Name of the container |
required |
download_directory
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 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 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 from container_name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_name |
str
|
Name of the container |
required |
get_directory_and_filename_from_full_path
staticmethod
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 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 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 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/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
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 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 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
|