BunnyTusClient class

Specialized TUS client for Bunny.net video uploads

Constructors

BunnyTusClient(XFile file, {TusStore? store, int maxChunkSize = 512 * 1024, int retries = 3, RetryScale retryScale = RetryScale.exponentialJitter, int retryInterval = 5, Duration connectionTimeout = const Duration(seconds: 30), Duration receiveTimeout = const Duration(seconds: 30), required String apiKey, required int libraryId, required String videoId, required String title, String? collectionId, int? thumbnailTime, int? expirationTimeInSeconds, String? checksumAlgorithm})

Properties

allowParallelFallback bool
getter/setter pairinherited
apiKey String
The API key for Bunny Stream
final
bestServers List<Server>?
List of Server that are good for testing speed
getter/setter pairinherited
cancelToken → CancelToken
finalinherited
checksumAlgorithm String?
Checksum algorithm to use for upload integrity verification
final
collectionId String?
The collection ID to upload to (optional)
final
connectionTimeout Duration
The number of parallel chunk uploads (defaults to 1 for sequential uploads) Connection timeout for network requests
finalinherited
enableCompression bool
Whether to use compression for uploads when supported
finalinherited
expirationTime int
The expiration time of the upload in seconds since epoch
final
file XFile
File to upload, must be inXFile type
finalinherited
fileSize int?
getter/setter pairinherited
fingerprint String
The fingerprint of the file being uploaded
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
Any additional headers
getter/setter pairinherited
libraryId int
The library ID where the video will be placed
final
maxChunkSize int
The maximum payload size in bytes when uploading the file in chunks (512KB)
finalinherited
metadata Map<String, String>?
getter/setter pairinherited
parallelUploads int
getter/setter pairinherited
partialUploadUrls List<Uri>?
getter/setter pairinherited
pauseUpload_ bool
getter/setter pairinherited
receiveTimeout Duration
Receive timeout for network requests
finalinherited
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
thumbnailTime int?
Video time in ms to extract the main video thumbnail (optional)
final
title String
The title of the video
final
tusVersion String
Version of the tus protocol used by the client. The remote server needs to support this version, too.
finalinherited
uploadCancelled bool
getter/setter pairinherited
uploadMetadata String
The 'Upload-Metadata' header sent to server
no setterinherited
uploadSpeed double?
Upload speed in Mb/s
getter/setter pairinherited
uploadUrl Uri?
The URI on the server for the file
no setterinherited
uploadUrl_ Uri?
getter/setter pairinherited
url Uri?
The tus server Uri
getter/setter pairinherited
videoId String
The video ID for the upload (must be pre-created)
final

Methods

cancelUpload() Future<bool>
Cancels the upload
inherited
createUpload() Future<void>
Create a new upload throwing ProtocolException on server error
customHeaders() Map<String, String>
Get the required Bunny.net authorization headers
dispose() → void
Cleanup resources when done
inherited
generateAuthorizationSignature() String
Generate the authorization signature required by Bunny.net Format: sha256(library_id + api_key + expiration_time + video_id)
generateFingerprint() String?
Override this method to customize creating file fingerprint
inherited
generateMetadata() String
Override this to customize creating 'Upload-Metadata'
inherited
getClient() → Dio
Override this method to use a custom Client
inherited
getCurrentOffset() Future<int>
Get the current offset for progress tracking (especially for resumed uploads)
getData() Future<Uint8List>
Override to add checksum header when uploading chunks
isResumable() Future<bool>
Checks if upload can be resumed.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCompleteUpload() Future<void>
Override onCompleteUpload to save additional metadata about the completed upload
parseOffset(String? offset) int?
inherited
pauseUpload() Future<bool>
Pause the current upload
inherited
setUploadData(Uri url, Map<String, String>? headers, Map<String, String>? metadata) → void
inherited
startUpload({dynamic onProgress(int, int, double, Duration)?, dynamic onStart(TusClient, Duration?)?, dynamic onComplete()?, bool measureUploadSpeed = false, bool forceNewUpload = false}) Future<void>
Helper method to create and start upload in a single call
terminateUpload() Future<bool>
Implement the termination extension for the TUS protocol
inherited
toString() String
A string representation of this object.
inherited
upload({dynamic onProgress(int, int, double, Duration)?, dynamic onStart(TusClient, Duration?)?, dynamic onComplete()?, required Uri uri, Map<String, String>? metadata = const {}, Map<String, String>? headers = const {}, bool measureUploadSpeed = false}) Future<void>
Start or resume an upload in chunks of maxChunkSize throwing ProtocolException on server error
inherited
uploadSpeedTest() Future<void>
Measures the upload speed of the device
inherited
uploadToBunny({dynamic onProgress(int, int, double, Duration)?, dynamic onStart(TusClient, Duration?)?, dynamic onComplete()?, bool measureUploadSpeed = false}) Future<void>
Start upload to Bunny.net

Operators

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

Constants

bunnyTusEndpoint → const String
The Bunny.net TUS upload endpoint