tusc 4.0.0 copy "tusc: ^4.0.0" to clipboard
tusc: ^4.0.0 copied to clipboard

A tus client for dart to allow resumable uploads using the tus protocol (https://tus.io/).

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Types of changes

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Removed for now removed features.
  • Fixed for any bug fixes.
  • Security in case of vulnerabilities.

4.0.0 #

Added #

  • Added sub chunk progress: onProgress is now called every progressSliceSize bytes while a chunk is being sent, defaulting to 64 KB, instead of only once the whole chunk has landed.
  • Added retryDelays to retry a request that failed on a transport error or on 408, 429 or a 5xx, defaulting to three retries after 1, 3 and 5 seconds; pass an empty list to keep failing on the first error.
  • Added close() to dispose of the internally created httpClient.
  • Added a check of the server's Upload-Length when resuming, so an upload belonging to a different file is replaced by a new one instead of being corrupted.
  • Added ProtocolException.statusCode as a shorthand for response?.statusCode.
  • Added resetSource(), called before a retry so a source that cannot be read backwards can start over.

Changed #

  • Breaking: an upload with a cache set now resumes a previously started upload instead of creating a new one on every startUpload(). Override generateFingerprint() if your creation url is one time or pre signed, such as a Cloudflare Stream direct upload URL, since the default fingerprint is derived from it.
  • The upload URL is now cached on every upload attempt, not only when the upload is created.
  • cancelUpload() now always returns a future, which completes once the cancellation and its cache removal have been recorded, and returns null only for an already completed upload.
  • Documented on generateFingerprint() what the fingerprint has to be stable and unique across.
  • Breaking: ProtocolException.response is now nullable, since a failure that did not come from a server response has none to report. Replace e.response.statusCode with e.statusCode, and e.response.x with e.response?.x.
  • Breaking: onProgress now reports bytes sent rather than bytes the server has confirmed, so its count can go backwards when a chunk fails and the offset is read back from the server, and its response is null for the reports made while a chunk is in flight.
  • Breaking: offset is now read only and maintained from what the server confirms. A getData() override must no longer advance it.
  • startUpload() and resumeUpload() called while an upload is already running now adopt the callbacks given to them and return the future of that upload, instead of starting a second chunk loop that fought the first one for the offset.
  • A Location response header is now resolved against the creation url following RFC 3986, so a path relative one no longer loses the base path.
  • chunkSize is now asserted to be greater than 0.

Fixed #

  • Fixed cached uploads never being read back, so an interrupted upload can now be resumed by a new client instance after an app restart or crash instead of silently starting over from zero.
  • Fixed an upload failing outright when the cached upload URL has expired or was swept server side, which now falls back to creating a new upload.
  • Fixed TusStreamClient uploading the wrong bytes when resuming a stream at a non zero offset.
  • Fixed the cache mapping possibly being lost when the process exits right after a chunk lands on the server.
  • Fixed a cancelled upload being resumed where it left off instead of starting over from the beginning.
  • Fixed pauseUpload() and cancelUpload() being silently ignored when no request was in flight, or when the request in flight completed before they took effect.
  • Fixed TusPersistentCache throwing a LateInitializationError when two calls opened its storage at the same time.
  • Fixed TusPersistentCache not waiting for writes and deletes to reach the disk.
  • Fixed TusPersistentCache setting the storage directory of the whole process, which sent every box the surrounding application opened after its first upload to the cache's directory instead of its own.
  • Fixed two TusPersistentCache instances over different paths sharing the storage of whichever one was opened first.
  • Fixed an upload whose source ran out of data early finishing silently, reporting neither an error nor completion.
  • Fixed generateMetadata() writing filename into the caller's metadata map, which also made a const map throw.
  • Fixed pauseUpload() and cancelUpload() rethrowing the error of a request that had already failed.
  • Fixed resumeUpload() dropping the onError callback, so errors were thrown instead of delivered after a resume.
  • Fixed the platform check picking the native implementation on a Flutter web app compiled to WebAssembly, which made TusPersistentCache treat a browser as a native platform.

3.0.0 #

Added #

  • Added support for resuming uploads using a direct uploadUrl, allowing the client to skip the upload creation step without requiring a cache.
  • Updated TusClient and TusStreamClient constructors to accept an optional uploadUrl.
  • Added clear() method to TusCache, TusMemoryCache, and TusPersistentCache.
  • Improved documentation and code examples in README.md and library files.
  • Added comprehensive assertion checks for url and uploadUrl parameters.

Changed #

  • Updated dart sdk constraints to sdk: '>=3.10.0 <4.0.0'

2.1.0 #

Added #

  • Added TusStreamClient to support stream uploads.

Changed #

  • Removed usage of dart:io to allow support for web.

Fixed #

  • Fixed error with TusPersistentCache keys limit of 255 chars length, due to Hive limitation. (Thanks bthnkucuk PR-2)

2.0.0 #

Changed #

  • Changed hive dependency to hive_ce.

1.2.0 #

Added #

  • Added onError callback to startUpload() function to allow getting errors through callback instead of thrown exceptions

1.1.0+3 #

Changed #

  • Updated http package version to '>=0.13.0 <2.0.0' for better compatibility.

1.1.0+2 #

Added #

  • TusUploadState enum added to control the state of the tus upload
  • tusclient.state to get the current upload state
  • tusclient.errorMessage to get the last error message
  • cancelUpload function added to TusClient

1.0.0+1 #

Changed #

  • README.md updated

1.0.0 #

  • Initial version.
14
likes
160
points
3.18k
downloads

Documentation

API reference

Publisher

verified publisherdev.lamt.dev

Weekly Downloads

A tus client for dart to allow resumable uploads using the tus protocol (https://tus.io/).

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

cross_file, crypto, hive_ce, http, path

More

Packages that depend on tusc