Downloaded File

class b2sdk.v2.DownloadedFile(download_version, download_manager, range_, response, encryption, progress_listener, write_buffer_size=None, check_hash=True)[source]

Result of a successful download initialization. Holds information about file’s metadata and allows to perform the download.

save(file, allow_seeking=None)[source]

Read data from B2 cloud and write it to a file-like object

Parameters:
  • file (BinaryIO) – a file-like object

  • allow_seeking (bool | None) – if False, download strategies that rely on seeking to write data (parallel strategies) will be discarded.

Return type:

None

save_to(path_, mode=None, allow_seeking=None)[source]

Open a local file and write data from B2 cloud to it, also update the mod_time.

Parameters:
  • path – path to file to be opened

  • mode (Literal[('wb', 'wb+')] | None) – mode in which the file should be opened

  • allow_seeking (bool | None) – if False, download strategies that rely on seeking to write data (parallel strategies) will be discarded.

  • path_ (str | pathlib.Path) –

Return type:

None

class b2sdk.v2.MtimeUpdatedFile(path_, mod_time_millis, mode='wb+', buffering=None)[source]

Helper class that facilitates updating a files mod_time after closing.

Over the time this class has grown, and now it also adds better exception handling.

Usage:

Parameters:
  • path_ (str | pathlib.Path) –

  • mod_time_millis (int) –

  • mode (Literal[('wb', 'wb+')]) –

  • buffering (int | None) –

property path_: str
write(value)[source]

This method is overwritten (monkey-patched) in __enter__ for performance reasons

read(*a)[source]

This method is overwritten (monkey-patched) in __enter__ for performance reasons

seekable()[source]

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

Return type:

bool

seek(offset, whence=0)[source]

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

tell()[source]

Return current stream position.