b2sdk.transfer.outbound.upload_source
- class b2sdk.transfer.outbound.upload_source.UploadMode(value)[source]
Bases:
Enum
Mode of file uploads
- FULL = 1
always upload the whole file
- INCREMENTAL = 2
use incremental uploads when possible
- class b2sdk.transfer.outbound.upload_source.AbstractUploadSource[source]
Bases:
OutboundTransferSource
The source of data for uploading to b2.
- abstract get_content_sha1()[source]
Returns a 40-character string containing the hex SHA1 checksum of the data in the file.
- Return type:
Sha1HexDigest | None
- class b2sdk.transfer.outbound.upload_source.UploadSourceBytes(data_bytes, content_sha1=None)[source]
Bases:
AbstractUploadSource
- class b2sdk.transfer.outbound.upload_source.UploadSourceLocalFileBase(local_path, content_sha1=None)[source]
Bases:
AbstractUploadSource
- Parameters:
local_path (os.PathLike | str) –
content_sha1 (Sha1HexDigest | None) –
- __init__(local_path, content_sha1=None)[source]
Initialize upload source using provided path.
- Parameters:
local_path (os.PathLike | str) – Any path-like object that points to a file to be uploaded.
content_sha1 (Sha1HexDigest | None) – SHA1 hexdigest of the data, or
None
.
- class b2sdk.transfer.outbound.upload_source.UploadSourceLocalFileRange(local_path, content_sha1=None, offset=0, length=None)[source]
Bases:
UploadSourceLocalFileBase
- Parameters:
local_path (os.PathLike | str) –
content_sha1 (Sha1HexDigest | None) –
offset (int) –
length (int | None) –
- __init__(local_path, content_sha1=None, offset=0, length=None)[source]
Initialize upload source using provided path.
- Parameters:
local_path (os.PathLike | str) – Any path-like object that points to a file to be uploaded.
content_sha1 (Sha1HexDigest | None) – SHA1 hexdigest of the data, or
None
.offset (int) – Position in the file where upload should start from.
length (int | None) – Amount of data to be uploaded. If
None
, length of the remainder of the file is taken.
- class b2sdk.transfer.outbound.upload_source.UploadSourceLocalFile(local_path, content_sha1=None)[source]
Bases:
UploadSourceLocalFileBase
- Parameters:
local_path (os.PathLike | str) –
content_sha1 (Sha1HexDigest | None) –
- get_incremental_sources(file_version, min_part_size=None)[source]
Split the upload into a copy and upload source constructing an incremental upload
This will return a list of upload sources. If the upload cannot split, the method will return [self].
- Parameters:
file_version (BaseFileVersion) –
min_part_size (int | None) –
- Return type:
- class b2sdk.transfer.outbound.upload_source.UploadSourceStream(stream_opener, stream_length=None, stream_sha1=None)[source]
Bases:
AbstractUploadSource
- Parameters:
- __init__(stream_opener, stream_length=None, stream_sha1=None)[source]
Initialize upload source using arbitrary function.
- Parameters:
stream_opener (Callable[[], io.IOBase]) – A function that opens a stream for uploading.
stream_length (int | None) – Length of the stream. If
None
, data will be calculated from the stream the first time it’s required.stream_sha1 (Sha1HexDigest | None) – SHA1 of the stream. If
None
, data will be calculated from the stream the first time it’s required.
- class b2sdk.transfer.outbound.upload_source.UploadSourceStreamRange(stream_opener, offset=0, stream_length=None, stream_sha1=None)[source]
Bases:
UploadSourceStream
- Parameters:
- __init__(stream_opener, offset=0, stream_length=None, stream_sha1=None)[source]
Initialize upload source using arbitrary function.
- Parameters:
stream_opener (Callable[[], io.IOBase]) – A function that opens a stream for uploading.
offset (int) – Offset from which stream should be uploaded.
stream_length (int | None) – Length of the stream. If
None
, data will be calculated from the stream the first time it’s required.stream_sha1 (Sha1HexDigest | None) – SHA1 of the stream. If
None
, data will be calculated from the stream the first time it’s required.