b2sdk.download_dest
– Download destination¶
-
class
b2sdk.download_dest.
AbstractDownloadDestination
[source]¶ Bases:
object
Interface to a destination for a downloaded file.
-
abstract
make_file_context
(file_id, file_name, content_length, content_type, content_sha1, file_info, mod_time_millis, range_=None)[source]¶ Return a context manager that yields a binary file-like object to use for writing the contents of the file.
- Parameters
file_id (str) – the B2 file ID from the headers
file_name (str) – the B2 file name from the headers
content_length (str) – the content length
content_type (str) – the content type from the headers
content_sha1 (str) – the content sha1 from the headers (or
"none"
for large files)file_info (dict) – the user file info from the headers
mod_time_millis (int) – the desired file modification date in ms since 1970-01-01
range (None,tuple[int,int]) – starting and ending offsets of the received file contents. Usually
None
, which means that the whole file is downloaded.
- Returns
None
-
abstract
-
class
b2sdk.download_dest.
DownloadDestLocalFile
(local_file_path)[source]¶ Bases:
b2sdk.download_dest.AbstractDownloadDestination
Store a downloaded file into a local file and sets its modification time.
-
MODE
= 'wb+'¶
-
make_file_context
(file_id, file_name, content_length, content_type, content_sha1, file_info, mod_time_millis, range_=None)[source]¶ Return a context manager that yields a binary file-like object to use for writing the contents of the file.
- Parameters
file_id (str) – the B2 file ID from the headers
file_name (str) – the B2 file name from the headers
content_length (str) – the content length
content_type (str) – the content type from the headers
content_sha1 (str) – the content sha1 from the headers (or
"none"
for large files)file_info (dict) – the user file info from the headers
mod_time_millis (int) – the desired file modification date in ms since 1970-01-01
range (None,tuple[int,int]) – starting and ending offsets of the received file contents. Usually
None
, which means that the whole file is downloaded.
- Returns
None
-
-
class
b2sdk.download_dest.
PreSeekedDownloadDest
(local_file_path, seek_target)[source]¶ Bases:
b2sdk.download_dest.DownloadDestLocalFile
Store a downloaded file into a local file and sets its modification time. Does not truncate the target file, seeks to a given offset just after opening a descriptor.
-
MODE
= 'rb+'¶
-
-
class
b2sdk.download_dest.
DownloadDestBytes
[source]¶ Bases:
b2sdk.download_dest.AbstractDownloadDestination
Store a downloaded file into bytes in memory.
-
make_file_context
(file_id, file_name, content_length, content_type, content_sha1, file_info, mod_time_millis, range_=None)[source]¶ Return a context manager that yields a binary file-like object to use for writing the contents of the file.
- Parameters
file_id (str) – the B2 file ID from the headers
file_name (str) – the B2 file name from the headers
content_length (str) – the content length
content_type (str) – the content type from the headers
content_sha1 (str) – the content sha1 from the headers (or
"none"
for large files)file_info (dict) – the user file info from the headers
mod_time_millis (int) – the desired file modification date in ms since 1970-01-01
range (None,tuple[int,int]) – starting and ending offsets of the received file contents. Usually
None
, which means that the whole file is downloaded.
- Returns
None
-
-
class
b2sdk.download_dest.
DownloadDestProgressWrapper
(download_dest, progress_listener)[source]¶ Bases:
b2sdk.download_dest.AbstractDownloadDestination
Wrap a DownloadDestination and report progress to a ProgressListener.
-
__init__
(download_dest, progress_listener)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
make_file_context
(file_id, file_name, content_length, content_type, content_sha1, file_info, mod_time_millis, range_=None)[source]¶ Return a context manager that yields a binary file-like object to use for writing the contents of the file.
- Parameters
file_id (str) – the B2 file ID from the headers
file_name (str) – the B2 file name from the headers
content_length (str) – the content length
content_type (str) – the content type from the headers
content_sha1 (str) – the content sha1 from the headers (or
"none"
for large files)file_info (dict) – the user file info from the headers
mod_time_millis (int) – the desired file modification date in ms since 1970-01-01
range (None,tuple[int,int]) – starting and ending offsets of the received file contents. Usually
None
, which means that the whole file is downloaded.
- Returns
None
-