Azure Block Blob¶
- class keg_storage.backends.azure.AzureStorage(account: str | None = None, key: str | None = None, bucket: str | None = None, sas_container_url: str | None = None, sas_blob_url: str | None = None, chunk_size=5242880, name: str = 'azure')[source]¶
- copy(path: str, new_path: str)¶
Copy the remote file specified by path to new_path.
- create_download_url(path: str, expire: Arrow | datetime)[source]¶
Create an SAS URL that can be used to download a blob without any additional authentication. This url may be accessed directly to download the blob:
requests.get(url)
- create_upload_url(path: str, expire: Arrow | datetime)[source]¶
Create an SAS URL that can be used to upload a blob without any additional authentication. This url can be used in following way to authenticate a client and upload to the pre-specified path:
client = BlobClient.from_blob_url(url) client.upload_blob(data)
- download(path: str, file_obj: IO, *, progress_callback: Callable[[int], None] | None = None)¶
Copies a remote file at path to a file-like object file_obj.
If desired, a progress callback can be supplied. The function should accept an int parameter, which will be the number of bytes downloaded so far.
- get(path: str, dest: str) None¶
Copies a remote file at path to the dest path given on the local filesystem.
- link_to(path: str, operation: ShareLinkOperation | str, expire: Arrow | datetime, output_path: str | None = None, content_type: str | None = None) str[source]¶
Returns a URL allowing direct the specified operations to be performed on the given path
- list(path: str) List[ListEntry][source]¶
Returns a list of ListEntry`s representing files available under the directory or prefix given in `path.
- open(path: str, mode: FileMode | str, extra_args=None) AzureFile[source]¶
Returns a instance of RemoteFile for the given path that can be used for reading and/or writing depending on the mode given.
- put(path: str, dest: str) None¶
Copies a local file at path to a remote file at dest.
- upload(file_obj: IO, path: str, *, progress_callback: Callable[[int], None] | None = None, extra_args=None)¶
Copies the contents of a file-like object file_obj to a remote file at path
If desired, a progress callback can be supplied. The function should accept an int parameter, which will be the number of bytes uploaded so far.
- class keg_storage.backends.azure.AzureReader(mode: FileMode, blob_client: BlobClient, chunk_size=5242880)[source]¶
The Azure reader uses byte ranged API calls to fill a local buffer to avoid lots of API overhead for small read sizes.
- class keg_storage.backends.azure.AzureWriter(mode: FileMode, blob_client: BlobClient, chunk_size=5242880)[source]¶
We are using Azure Block Blobs for all operations. The process for writing them is substantially similar to that of S3 with a couple of differences.
We generate the IDs for the blocks
- There is no separate call to instantiate the upload. The first call to put_block will create
the blob.
- class keg_storage.backends.azure.AzureFile(mode: FileMode, blob_client: BlobClient, chunk_size=5242880)[source]¶
Base class for Azure file interface. Since read and write operations are very different and integrating the two would introduce a lot of complexity there are distinct subclasses for files opened for reading and writing.