TusClient class

This class is used for creating or resuming uploads.

Constructors

TusClient(XFile file, {TusStore? store, int maxChunkSize = 512 * 1024, int retries = 0, RetryScale retryScale = RetryScale.constant, int retryInterval = 0, bool debug = false})
Create a new TusClient

Properties

bestServers List<Server>?
List of Server that are good for testing speed
getter/setter pairinherited
debug bool
Debug flag to enable verbose logging
final
file → XFile
The file being uploaded
no setter
fingerprint String
The fingerprint of the file being uploaded
no setter
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
Any additional headers
getter/setter pairinherited
maxChunkSize int
The maximum payload size in bytes when uploading the file in chunks (512KB)
finalinherited
metadata Map<String, String>?
getter/setter pairinherited
resumingEnabled bool
Whether the client supports resuming
no setterinherited
retries int
The number of times that should retry to resume the upload if a failure occurs after rethrow the error.
finalinherited
retryInterval int
The interval between the first error and the first retry in seconds.
finalinherited
retryScale RetryScale
The scale type used to increase the interval of time between every retry.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
store TusStore?
Storage used to save and retrieve upload URLs by its fingerprint.
finalinherited
tusVersion String
Version of the tus protocol used by the client. The remote server needs to support this version, too.
finalinherited
uploadMetadata String
The 'Upload-Metadata' header sent to server
no setter
uploadSpeed double?
Upload speed in Mb/s
getter/setter pairinherited
uploadUrl Uri?
The URI on the server for the file
no setter
url Uri?
The tus server Uri
getter/setter pairinherited

Methods

cancelUpload() Future<bool>
Cancel the current upload and remove it from the store
checkExistingUpload() Future<(bool, bool)>
Checks if an upload with the same fingerprint already exists and can be resumed Returns a tuple of (exists, canResume)
clearAllCallbacks() → void
Helper method to clear all callbacks at once without calling resume
createUpload() Future<void>
Create a new upload throwing ProtocolException on server error
generateFingerprint() String
Generate a fingerprint for the file
generateMetadata() String
Override this to customize creating 'Upload-Metadata'
inherited
getHttpClient() → Client
Override this method to use a custom HTTP Client
isResumable() Future<bool>
Checks if upload can be resumed, including verification with the server. Returns true if the upload exists both in the local store and on the server.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCompleteUpload() Future<void>
Actions to be performed after a successful upload
pauseUpload() Future<bool>
Pause the current upload
resumeUpload({dynamic onProgress(double, Duration)?, bool clearProgressCallback = false, dynamic onStart(TusClient, Duration?)?, bool clearStartCallback = false, dynamic onComplete()?, bool clearCompleteCallback = false}) Future<void>
Resume a previously paused upload with intelligent callback handling
setUploadData(Uri url, Map<String, String>? headers, Map<String, String>? metadata) → void
Set the upload data for the client
setUploadTestServers() Future<void>
Sets to servers to test for upload speed
toString() String
A string representation of this object.
inherited
upload({dynamic onProgress(double, Duration)?, dynamic onStart(TusClient, Duration?)?, dynamic onComplete()?, required Uri uri, Map<String, String>? metadata = const {}, Map<String, String>? headers = const {}, bool measureUploadSpeed = false, bool preventDuplicates = true}) Future<void>
Start or resume an upload in chunks of maxChunkSize throwing ProtocolException on server error
uploadSpeedTest() Future<void>
Measures the upload speed of the device

Operators

operator ==(Object other) bool
The equality operator.
inherited