Exceptions & Utilities¶
Exceptions¶
Client Exceptions¶
| Exception | Raised when |
|---|---|
TusCommunicationError |
HTTP/network error during create, HEAD, DELETE, or server info requests |
TusUploadFailed |
Chunk upload fails after all retry attempts, or upload is cancelled via stop_event / on_should_retry=False |
TusUploadFailed is a subclass of TusCommunicationError.
Both exceptions expose:
message(str): Human-readable error descriptionstatus_code(int | None): HTTP status code, if availableresponse_content(bytes | None): Raw response body, if available
Server Exceptions¶
| Exception | Raised when |
|---|---|
TusHookError |
Raised in server hooks to reject a request with a specific status code and body |
from resumable_upload.exceptions import TusHookError
raise TusHookError("Forbidden", status_code=403) # status_code defaults to 400
status_code(int): HTTP status code to return to the client (default: 400)body(str): Response body to return to the client
Fingerprint¶
File fingerprinting for identifying uploads across sessions. Three strategies ship; all subclass Fingerprint.
Fingerprint (default)¶
SHA-256 of the full file content combined with file size — size:{bytes}--sha256:{hex}. Two files with identical first bytes but different content always produce different fingerprints. Slowest but collision-resistant.
PartialMD5Fingerprint¶
fp = PartialMD5Fingerprint(probe_bytes=64 * 1024)
key = fp.get_fingerprint("large_file.bin")
# e.g. "size:1048576--md5:..."
Cheap strategy — MD5 of the first probe_bytes bytes plus the file size. Matches tus-py-client's default fingerprint format (size:<n>--md5:<hex>), so URL-storage entries can interoperate with that client if you share the same storage file. Higher collision rate than the SHA-256 default; a false match falls back to a server-side 404 at worst.
CallableFingerprint¶
def my_fp(file_source) -> str:
return f"user-42:{file_source}"
client = TusClient("...", fingerprinter=CallableFingerprint(my_fp))
Adapter that forwards to a user-supplied function. Lets you plug in domain-specific identity schemes (e.g., user id + filename, a CDN URL, a database primary key) without subclassing.
Note: This fingerprint is an internal client-side feature for resumability and is not part of the TUS protocol. The TUS
Upload-Checksumextension separately uses one ofsha1/sha256/sha512/md5for per-chunk integrity, configured server-side viachecksum_algorithms=.