Downloaded File

class b2sdk.v2.DownloadedFile(download_version: b2sdk.file_version.DownloadVersion, download_manager: DownloadManager, range_: Optional[Tuple[int, int]], response: requests.models.Response, encryption: Optional[b2sdk.encryption.setting.EncryptionSetting], progress_listener: b2sdk.progress.AbstractProgressListener)[source]

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

save(file, allow_seeking=True)[source]

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

Parameters
  • file – a file-like object

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

save_to(path_, mode='wb+', allow_seeking=True)[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 – mode in which the file should be opened

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

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

Helper class that facilitates updating a files mod_time after closing. Usage:

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

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.