Data classes
- class b2sdk.v2.FileVersion(api, id_, file_name, size, content_type, content_sha1, file_info, upload_timestamp, account_id, bucket_id, action, content_md5, server_side_encryption, file_retention=FileRetentionSetting(None, None), legal_hold=LegalHold.UNSET, replication_status=None, cache_control=None)[source]
A structure which represents a version of a file (in B2 cloud).
- Variables:
~.id_ (str) –
fileId
~.file_name (str) – full file name (with path)
~.size – size in bytes, can be
None
(unknown)~.content_type (str) – RFC 822 content type, for example
"application/octet-stream"
~.upload_timestamp – in milliseconds since epoch. Can be
None
(unknown).~.action (str) –
"upload"
,"hide"
or"delete"
- Parameters:
api (B2Api) –
id_ (str) –
file_name (str) –
content_type (str | None) –
content_sha1 (str | None) –
upload_timestamp (int) –
account_id (str) –
bucket_id (str) –
action (str) –
content_md5 (str | None) –
server_side_encryption (EncryptionSetting) –
file_retention (FileRetentionSetting) –
legal_hold (LegalHold) –
replication_status (ReplicationStatus | None) –
cache_control (str | None) –
- DEFAULT_HEADERS_LIMIT = 7000
- ADVANCED_HEADERS_LIMIT = 2048
- account_id
- bucket_id
- content_md5
- action
- as_dict()[source]
represents the object as a dict which looks almost exactly like the raw api output for upload/list
- get_fresh_state()[source]
Fetch all the information about this file version and return a new FileVersion object. This method does NOT change the object it is called on.
- Return type:
- download(progress_listener=None, range_=None, encryption=None)[source]
- Parameters:
progress_listener (AbstractProgressListener | None) –
encryption (EncryptionSetting | None) –
- Return type:
- property has_large_header: bool
Determine whether FileVersion’s info fits header size limit defined by B2. This function makes sense only for “advanced” buckets, i.e. those which have Server-Side Encryption or File Lock enabled.
See https://www.backblaze.com/b2/docs/files.html#httpHeaderSizeLimit.
- api
- cache_control
- content_sha1
- content_sha1_verified
- content_type
- delete(bypass_governance=False)
Delete this file version. bypass_governance must be set to true if deleting a file version protected by Object Lock governance mode retention settings (unless its retention period expired)
- Parameters:
bypass_governance (
bool
) –- Return type:
- file_info
- file_name
- file_retention
- get_content_sha1()
Get the file’s content SHA1 hex digest from the header or, if its absent, from the file info. If both are missing, return None.
- Return type:
Sha1HexDigest | None
- id_
- legal_hold
- mod_time_millis
- replication_status
- server_side_encryption
- size
- update_retention(file_retention, bypass_governance=False)
- Parameters:
file_retention (
FileRetentionSetting
) –bypass_governance (
bool
) –
- Return type:
BaseFileVersion
- upload_timestamp
- class b2sdk.v2.DownloadVersion(api, id_, file_name, size, content_type, content_sha1, file_info, upload_timestamp, server_side_encryption, range_, content_disposition, content_length, content_language, expires, cache_control, content_encoding, file_retention=FileRetentionSetting(None, None), legal_hold=LegalHold.UNSET, replication_status=None)[source]
A structure which represents metadata of an initialized download
- Parameters:
api (B2Api) –
id_ (str) –
file_name (str) –
size (int) –
content_type (str | None) –
content_sha1 (str | None) –
upload_timestamp (int) –
server_side_encryption (EncryptionSetting) –
range_ (Range) –
content_disposition (str | None) –
content_length (int) –
content_language (str | None) –
content_encoding (str | None) –
file_retention (FileRetentionSetting) –
legal_hold (LegalHold) –
replication_status (ReplicationStatus | None) –
- range_
- content_disposition
- content_length
- content_language
- content_encoding
- api
- as_dict()
represents the object as a dict which looks almost exactly like the raw api output for upload/list
- cache_control
- content_sha1
- content_sha1_verified
- content_type
- delete(bypass_governance=False)
Delete this file version. bypass_governance must be set to true if deleting a file version protected by Object Lock governance mode retention settings (unless its retention period expired)
- Parameters:
bypass_governance (
bool
) –- Return type:
- file_info
- file_name
- file_retention
- get_content_sha1()
Get the file’s content SHA1 hex digest from the header or, if its absent, from the file info. If both are missing, return None.
- Return type:
Sha1HexDigest | None
- id_
- legal_hold
- mod_time_millis
- replication_status
- server_side_encryption
- size
- update_retention(file_retention, bypass_governance=False)
- Parameters:
file_retention (
FileRetentionSetting
) –bypass_governance (
bool
) –
- Return type:
BaseFileVersion
- upload_timestamp
- class b2sdk.v2.FileIdAndName(file_id, file_name)[source]
A structure which represents a B2 cloud file with just file_name and fileId attributes.
Used to return data from calls to b2_delete_file_version and b2_cancel_large_file.
- as_dict()[source]
represents the object as a dict which looks almost exactly like the raw api output for delete_file_version
- __dict__ = mappingproxy({'__module__': 'b2sdk.file_version', '__doc__': '\n A structure which represents a B2 cloud file with just `file_name` and `fileId` attributes.\n\n Used to return data from calls to b2_delete_file_version and b2_cancel_large_file.\n ', '__init__': <function FileIdAndName.__init__>, 'from_cancel_or_delete_response': <classmethod object>, 'as_dict': <function FileIdAndName.as_dict>, '__eq__': <function FileIdAndName.__eq__>, '__repr__': <function FileIdAndName.__repr__>, '__dict__': <attribute '__dict__' of 'FileIdAndName' objects>, '__weakref__': <attribute '__weakref__' of 'FileIdAndName' objects>, '__hash__': None, '__annotations__': {}})
- class b2sdk.v2.UnfinishedLargeFile[source]
A structure which represents a version of a file (in B2 cloud).