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
|
The name of the blob being downloaded. |
container
|
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
|
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
|
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
|
The number of parallel connections with which to download. Default value: 1
|
encoding
|
Test encoding to decode the downloaded bytes. Default is UTF-8. Default value: UTF-8
|
Returns
Type | Description |
---|---|
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
|
The number of parallel connections with which to download. Default value: 1
|
Returns
Type | Description |
---|---|
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[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 |
---|---|
The number of bytes read. |
Azure SDK for Python
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for