in azure/multiapi/storage/v2015_04_05/blob/baseblobservice.py [0:0]
def get_blob_to_path(
self, container_name, blob_name, file_path, open_mode='wb',
snapshot=None, start_range=None, end_range=None,
range_get_content_md5=None, progress_callback=None,
max_connections=1, max_retries=5, retry_wait=1.0, lease_id=None,
if_modified_since=None, if_unmodified_since=None,
if_match=None, if_none_match=None, timeout=None):
'''
Downloads a blob to a file path, with automatic chunking and progress
notifications. Returns an instance of :class:`Blob` with
properties and metadata.
:param str container_name:
Name of existing container.
:param str blob_name:
Name of existing blob.
:param str file_path:
Path of file to write out to.
:param str open_mode:
Mode to use when opening the file.
:param str snapshot:
The snapshot parameter is an opaque DateTime value that,
when present, specifies the blob snapshot to retrieve.
:param int start_range:
Start of byte range to use for downloading a section of the blob.
If no end_range is given, all bytes after the start_range will be downloaded.
The start_range and end_range params are inclusive.
Ex: start_range=0, end_range=511 will download first 512 bytes of blob.
:param int end_range:
End of byte range to use for downloading a section of the blob.
If end_range is given, start_range must be provided.
The start_range and end_range params are inclusive.
Ex: start_range=0, end_range=511 will download first 512 bytes of blob.
:param bool range_get_content_md5:
When this header is set to True and specified together
with the Range header, the service returns the MD5 hash for the
range, as long as the range is less than or equal to 4 MB in size.
:param progress_callback:
Callback for progress with signature function(current, total)
where current is the number of bytes transfered so far, and total is
the size of the blob if known.
:type progress_callback: callback function in format of func(current, total)
:param int max_connections:
Set to 1 to download the blob sequentially.
Set to 2 or greater if you want to download a blob larger than 64MB in chunks.
If the blob size does not exceed 64MB it will be downloaded in one chunk.
:param int max_retries:
Number of times to retry download of blob chunk if an error occurs.
:param int retry_wait:
Sleep time in secs between retries.
:param str lease_id:
Required if the blob has an active lease.
:param datetime if_modified_since:
A DateTime value. Azure expects the date value passed in to be UTC.
If timezone is included, any non-UTC datetimes will be converted to UTC.
If a date is passed in without timezone info, it is assumed to be UTC.
Specify this header to perform the operation only
if the resource has been modified since the specified time.
:param datetime if_unmodified_since:
A DateTime value. Azure expects the date value passed in to be UTC.
If timezone is included, any non-UTC datetimes will be converted to UTC.
If a date is passed in without timezone info, it is assumed to be UTC.
Specify this header to perform the operation only if
the resource has not been modified since the specified date/time.
:param str if_match:
An ETag value, or the wildcard character (*). Specify this header to perform
the operation only if the resource's ETag matches the value specified.
:param str if_none_match:
An ETag value, or the wildcard character (*). Specify this header
to perform the operation only if the resource's ETag does not match
the value specified. Specify the wildcard character (*) to perform
the operation only if the resource does not exist, and fail the
operation if it does exist.
:param int timeout:
The timeout parameter is expressed in seconds. This method may make
multiple calls to the Azure service and the timeout will apply to
each call individually.
:return: A Blob with properties and metadata.
:rtype: :class:`~azure.storage.blob.models.Blob`
'''
_validate_not_none('container_name', container_name)
_validate_not_none('blob_name', blob_name)
_validate_not_none('file_path', file_path)
_validate_not_none('open_mode', open_mode)
with open(file_path, open_mode) as stream:
blob = self.get_blob_to_stream(
container_name,
blob_name,
stream,
snapshot,
start_range,
end_range,
range_get_content_md5,
progress_callback,
max_connections,
max_retries,
retry_wait,
lease_id,
if_modified_since,
if_unmodified_since,
if_match,
if_none_match,
timeout)
return blob