The ultimate Flutter package for TUS uploads.
Tus is an open-source protocol that enables efficient file uploads, downloads, and storage. Tus offers several features such as resumable uploads, parallel uploading, and byte-range requests. tus_client_dart implements this protocol entirely in Dart, providing developers with an easy-to-use, feature-rich, and reliable way to upload and download files.
The usage of this package is as simple as instancing the TusClient class
import 'package:cross_file/cross_file.dart' show XFile;
// File to be uploaded
final file = XFile("/path/to/my/pic.jpg");
// Create a client
final client = TusClient(
Uri.parse("https://master.tus.io/files/"),
file,
store: TusMemoryStore(),
);
And use the upload method to start the upload, having the chance to specify the behavior on the start, progress and finish.
// Starts the upload
await client.upload(
onStart:(TusClient client, Duration? estimate){
// If estimate is not null, it will provide the estimate time for completion
// it will only be not null if measuring upload speed
print('This is the client to be used $client and $estimate time');
},
onComplete: () {
print("Complete!");
// Prints the uploaded file URL
print(client.uploadUrl.toString());
},
onProgress: (double progress, Duration estimate, TusClient client) {
print("Progress: $progress, Estimated time: ${estimate.inSeconds}");
},
// Set this to true if you want to measure upload speed at the start of the upload
measureUploadSpeed: true,
);
One of the most significant advantages of tus_client_dart over other tus client packages is its excellent time estimation feature. This feature provides developers with an accurate estimation of the time required to upload or download a file. This estimation is based on the file size, transfer speed, and network conditions, and it allows developers to plan accordingly.
Another great feature of tus_client_dart is its small steps in progress feedback. This feature provides developers with real-time feedback on the progress of file transfers. Developers can view the progress of uploads and downloads in small increments, allowing them to monitor the transfer progress in real-time.
Finally, tus_client_dart also offers an out-of-the-box retry mechanism. This mechanism automatically retries failed uploads and downloads, reducing the need for manual intervention. This feature ensures that uploads and downloads are successful, even in the face of intermittent network connectivity or other issues.
Another great feature of tus_client_dart is that its implementation is straightforward and well-documented. The package page on pub.dev provides comprehensive documentation, including a step-by-step guide on how to use the package to upload and download files.
The documentation is easy to follow, with clear examples and explanations of each step. This makes it easy for developers, regardless of their level of expertise, to integrate tus_client_dart into their projects quickly and effectively.
Furthermore, the package page also includes information on the package’s configuration options, including how to set custom headers, how to specify the maximum number of retries, and how to set timeouts for uploads and downloads.
In summary, tus_client_dart is an awesome Flutter package that implements the tus protocol entirely in Dart. It offers excellent time estimation, real-time progress feedback, and an out-of-the-box retry mechanism, making it an ideal package for developers who need a reliable and feature-rich way to upload and download files. If you’re looking for a powerful tus client package for your next Flutter project, tus_client_dart is definitely worth checking out!