StorageStreamDownloader Class

A streaming object to download from Azure Storage.

Inheritance
StorageStreamDownloader

Constructor

StorageStreamDownloader(clients=None, config=None, start_range=None, end_range=None, validate_content=None, encryption_options=None, max_concurrency=1, name=None, container=None, encoding=None, download_cls=None, **kwargs)

Parameters

Name Description
clients
default value: None
config
default value: None
start_range
default value: None
end_range
default value: None
validate_content
default value: None
encryption_options
default value: None
max_concurrency
default value: 1
name
default value: None
container
default value: None
encoding
default value: None
download_cls
default value: None

Variables

Name Description
name
str

The name of the blob being downloaded.

container
str

The name of the container where the blob is.

properties

The properties of the blob being downloaded. If only a range of the data is being downloaded, this will be reflected in the properties.

size
int

The size of the total data in the stream. This will be the byte range if specified, otherwise the total size of the blob.

Methods

chunks

Iterate over chunks in the download stream.

content_as_bytes

DEPRECATED: Download the contents of this file.

This operation is blocking until all data is downloaded.

This method is deprecated, use func:readall instead.

content_as_text

DEPRECATED: Download the contents of this blob, and decode as text.

This operation is blocking until all data is downloaded.

This method is deprecated, use func:readall instead.

download_to_stream

DEPRECATED: Download the contents of this blob to a stream.

This method is deprecated, use func:readinto instead.

read

Read up to size bytes from the stream and return them. If size is unspecified or is -1, all bytes will be read.

readall

Read the entire contents of this blob. This operation is blocking until all data is downloaded.

readinto

Download the contents of this blob to a stream.

chunks

Iterate over chunks in the download stream.

chunks() -> AsyncIterator[bytes]

Returns

Type Description

An async iterator of the chunks in the download stream.

content_as_bytes

DEPRECATED: Download the contents of this file.

This operation is blocking until all data is downloaded.

This method is deprecated, use func:readall instead.

async content_as_bytes(max_concurrency=1)

Parameters

Name Description
max_concurrency
int

The number of parallel connections with which to download.

default value: 1

Returns

Type Description

The contents of the file as bytes.

content_as_text

DEPRECATED: Download the contents of this blob, and decode as text.

This operation is blocking until all data is downloaded.

This method is deprecated, use func:readall instead.

async content_as_text(max_concurrency=1, encoding='UTF-8')

Parameters

Name Description
max_concurrency
int

The number of parallel connections with which to download.

default value: 1
encoding
str

Test encoding to decode the downloaded bytes. Default is UTF-8.

default value: UTF-8

Returns

Type Description
str

The content of the file as a str.

download_to_stream

DEPRECATED: Download the contents of this blob to a stream.

This method is deprecated, use func:readinto instead.

async download_to_stream(stream, max_concurrency=1)

Parameters

Name Description
stream
Required
IO[<xref:T>]

The stream to download to. This can be an open file-handle, or any writable stream. The stream must be seekable if the download uses more than one parallel connection.

max_concurrency
int

The number of parallel connections with which to download.

default value: 1

Returns

Type Description
Any

The properties of the downloaded blob.

read

Read up to size bytes from the stream and return them. If size is unspecified or is -1, all bytes will be read.

async read(size: int | None = -1) -> T

Parameters

Name Description
size

The number of bytes to download from the stream. Leave unspecified or set to -1 to download all bytes.

default value: -1

Returns

Type Description
<xref:T>

The requested data as bytes or a string if encoding was specified. If the return value is empty, there is no more data to read.

readall

Read the entire contents of this blob. This operation is blocking until all data is downloaded.

async readall() -> T

Returns

Type Description
<xref:T>

The requested data as bytes or a string if encoding was specified.

readinto

Download the contents of this blob to a stream.

async readinto(stream: IO[T]) -> int

Parameters

Name Description
stream
Required
IO[<xref:T>]

The stream to download to. This can be an open file-handle, or any writable stream. The stream must be seekable if the download uses more than one parallel connection.

Returns

Type Description
int

The number of bytes read.