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:
- cache_control
- as_dict()[source]
represents the object as a dict which looks almost exactly like the raw api output for upload/list
- ADVANCED_HEADERS_LIMIT = 2048
- DEFAULT_HEADERS_LIMIT = 7000
- account_id
- action
- api
- bucket_id
- content_md5
- 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:
- download(progress_listener=None, range_=None, encryption=None)[source]
- Parameters:
progress_listener (
Optional
[AbstractProgressListener
]) –encryption (
Optional
[EncryptionSetting
]) –
- Return type:
- expires_parsed()[source]
Return the expiration date as a datetime object, or None if there is no expiration date. Raise ValueError if expires property is not a valid HTTP-date.
- 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.
- 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:
FileVersion
- 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.
- 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
) –upload_timestamp (
int
) –server_side_encryption (
EncryptionSetting
) –range_ (
Range
) –content_length (
int
) –file_retention (
FileRetentionSetting
) –legal_hold (
LegalHold
) –replication_status (
Optional
[ReplicationStatus
]) –
- range_
- content_disposition
- content_length
- content_language
- expires
- cache_control
- content_encoding
- expires_parsed()[source]
Return the expiration date as a datetime object, or None if there is no expiration date. Raise ValueError if expires property is not a valid HTTP-date.
- as_dict()[source]
represents the object as a dict which looks almost exactly like the raw api output for upload/list
- Return type:
- api
- 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.
- 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._internal.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(<function FileIdAndName.from_cancel_or_delete_response>)>, '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).