Dela via


StorageStreamDownloader Class

A streaming object to download from Azure Storage.

Constructor

StorageStreamDownloader(downloader: Any)

Parameters

Name Description
downloader
Required

Methods

chunks

Iterate over chunks in the download stream.Note, the iterator returned will iterate over the entire download content, regardless of any data that was previously read.

NOTE: If the stream has been partially read, some data may be re-downloaded by the iterator.

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

Download the contents of this file.

This operation is blocking until all data is downloaded.

readinto

Download the contents of this file to a stream.

chunks

Iterate over chunks in the download stream.Note, the iterator returned will iterate over the entire download content, regardless of any data that was previously read.

NOTE: If the stream has been partially read, some data may be re-downloaded by the iterator.

chunks() -> AsyncIterator[bytes]

Returns

Type Description

An async iterator over the chunks in the download stream.

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 = -1) -> bytes

Parameters

Name Description
size
int

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

The requested data as bytes. If the return value is empty, there is no more data to read.

readall

Download the contents of this file.

This operation is blocking until all data is downloaded.

async readall() -> bytes

Returns

Type Description

The contents of the file.

readinto

Download the contents of this file to a stream.

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

Parameters

Name Description
stream
Required

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.

Attributes

name

The name of the file being downloaded.

name: str

properties

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

properties: FileProperties

size

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

size: int