tusc 4.0.0
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
Addedfor new features.Changedfor changes in existing functionality.Deprecatedfor soon-to-be removed features.Removedfor now removed features.Fixedfor any bug fixes.Securityin case of vulnerabilities.
4.0.0 #
Added #
- Added sub chunk progress:
onProgressis now called everyprogressSliceSizebytes while a chunk is being sent, defaulting to 64 KB, instead of only once the whole chunk has landed. - Added
retryDelaysto 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 createdhttpClient. - Added a check of the server's
Upload-Lengthwhen resuming, so an upload belonging to a different file is replaced by a new one instead of being corrupted. - Added
ProtocolException.statusCodeas a shorthand forresponse?.statusCode. - Added
resetSource(), called before a retry so a source that cannot be read backwards can start over.
Changed #
- Breaking: an upload with a
cacheset now resumes a previously started upload instead of creating a new one on everystartUpload(). OverridegenerateFingerprint()if your creationurlis 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 returnsnullonly for an already completed upload.- Documented on
generateFingerprint()what the fingerprint has to be stable and unique across. - Breaking:
ProtocolException.responseis now nullable, since a failure that did not come from a server response has none to report. Replacee.response.statusCodewithe.statusCode, ande.response.xwithe.response?.x. - Breaking:
onProgressnow reports bytes sent rather than bytes the server has confirmed, so itscountcan go backwards when a chunk fails and the offset is read back from the server, and itsresponseisnullfor the reports made while a chunk is in flight. - Breaking:
offsetis now read only and maintained from what the server confirms. AgetData()override must no longer advance it. startUpload()andresumeUpload()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
Locationresponse header is now resolved against the creationurlfollowing RFC 3986, so a path relative one no longer loses the base path. chunkSizeis 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
TusStreamClientuploading 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()andcancelUpload()being silently ignored when no request was in flight, or when the request in flight completed before they took effect. - Fixed
TusPersistentCachethrowing aLateInitializationErrorwhen two calls opened its storage at the same time. - Fixed
TusPersistentCachenot waiting for writes and deletes to reach the disk. - Fixed
TusPersistentCachesetting 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
TusPersistentCacheinstances 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()writingfilenameinto the caller'smetadatamap, which also made aconstmap throw. - Fixed
pauseUpload()andcancelUpload()rethrowing the error of a request that had already failed. - Fixed
resumeUpload()dropping theonErrorcallback, 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
TusPersistentCachetreat 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
TusClientandTusStreamClientconstructors to accept an optionaluploadUrl. - Added
clear()method toTusCache,TusMemoryCache, andTusPersistentCache. - Improved documentation and code examples in
README.mdand library files. - Added comprehensive assertion checks for
urlanduploadUrlparameters.
Changed #
- Updated dart sdk constraints to
sdk: '>=3.10.0 <4.0.0'
2.1.0 #
1.2.0 #
Added #
- Added
onErrorcallback tostartUpload()function to allow getting errors through callback instead of thrown exceptions
1.1.0+2 #
Added #
TusUploadStateenum added to control the state of the tus uploadtusclient.stateto get the current upload statetusclient.errorMessageto get the last error messagecancelUploadfunction added toTusClient
1.0.0 #
- Initial version.