The b2sdk supports continuing interrupted upload or creation sessions for large files. Continuation can be handled in two ways:
1. Automatic Continuation
For local-only input sources, b2sdk.v3.Bucket.create_file automatically attempts to find and resume an unfinished large file with the same file_name, file_info, and media type. It verifies checksums of uploaded parts against local sources to select the most complete valid candidate.
For other input types (e.g., remote sources), the SDK uses 'plan information' stored in the file_info. It looks for an unfinished large file with matching plan info and verifies checksums. If checksum verification fails for all candidates, an error is raised; in this case, you should manually cancel the corrupted unfinished files and retry, or disable auto-continuation.
2. Manual Continuation
If automatic continuation is not available or you want to avoid ambiguity when multiple matching sessions exist, you can use the large_file_id. You can extract this ID via the large_file_callback during the initial operation and pass it into the subsequent call.
Support Matrix:
b2sdk.v3.Bucket.create_file: Supports both automatic and manual continuation.b2sdk.v3.Bucket.create_file_stream: Supports only manual continuation for local-only inputs.b2sdk.v3.Bucket.concatenate and b2sdk.v3.Bucket.concatenate_stream: concatenate_stream supports only manual continuation of local sources.b2sdk.v3.Bucket.upload and b2sdk.v3.Bucket.copy: Support both automatic and manual continuation.
# Manual continuation example
def large_file_callback(large_file):
# Store the ID (e.g., in a database) to use later
storage.store({'name': remote_name, 'large_file_id': large_file.id})
# Initial attempt
bucket.create_file(input_sources, remote_name, file_info, large_file_callback=large_file_callback)
# ... later, to resume ...
large_file_id = storage.query({'name': remote_name})[0]['large_file_id']
bucket.create_file(input_sources, remote_name, file_info, large_file_id=large_file_id)