RFC: TUS Resumable Upload Protocol Implementation #799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RFC: TUS Resumable Upload Protocol Implementation
Summary
This PR introduces a Swift implementation of the TUS (Tus Resumable Upload Protocol) 1.0.0 for the Supabase Storage module. This is a port of the existing Kotlin implementation from the community supabase-kt library.
Background
The TUS protocol enables resumable file uploads, allowing clients to pause and resume uploads even after network interruptions or application restarts. This is particularly valuable for:
Implementation
This implementation is a direct port of the Kotlin TUS implementation from:
Key Components
Features
✅ Resumable Uploads: Automatic resumption from last uploaded offset
✅ Progress Tracking: Real-time progress updates via
AsyncStream
✅ Pause/Resume: Programmatic control over upload state
✅ Retry Logic: Configurable retry attempts with exponential backoff
✅ Thread Safety: Actor-based design for concurrent access
✅ Disk Persistence: Upload sessions survive app restarts
✅ TUS 1.0.0 Compliance: Full protocol implementation
Usage Example
API Design
The implementation follows Swift conventions while maintaining compatibility with the TUS protocol:
actor
for thread-safe state managementAsyncStream
for reactive progress updatesStorageFileApi
Testing
Migration Path
This is an additive feature that doesn't break existing upload functionality. Developers can opt-in to resumable uploads when needed while continuing to use standard uploads for smaller files.
Questions for Review
upload()
methods or kept as separate API?Related Links
🤖 Generated with Claude Code