Concurrent Upload Architecture
r2Vault uploads multiple files simultaneously using Swift’s structured concurrency, maximizing your upload speed while respecting R2’s limits.AppViewModel.swift:472-494
Each upload runs in its own concurrent task, allowing multiple files to upload simultaneously while maintaining full control over individual uploads.
Upload Service
The core upload logic uses Cloudflare R2’s S3-compatible API with AWS V4 signature authentication:R2UploadService.swift:19-50
Files are uploaded directly from disk using
URLSession.upload(for:fromFile:), which streams the file without loading it entirely into memory.Progress Tracking
Each upload task tracks its progress in real-time using a custom URLSession delegate:R2UploadService.swift:73-94
AppViewModel.swift:545-555
Upload Task Model
Each upload is represented by aFileUploadTask observable object:
UploadTask.swift:1-46
Pending
Waiting in queue to start
Uploading
Currently uploading with progress
Completed
Successfully uploaded
Failed
Upload failed with error message
Cancel Functionality
Any upload can be cancelled at any time by clicking the cancel button:UploadTask.swift:41-45
AppViewModel.swift:584-587
Upload History
Successful uploads are automatically saved to local history:AppViewModel.swift:557-578
Upload history is persisted locally and survives app restarts. You can view and manage your upload history from the menu bar widget.
Public URL Generation
Every uploaded file automatically gets a public URL that’s copied to your clipboard:For custom domains, you can configure your R2 bucket with a CNAME record. The public URL will use your custom domain instead of the default R2 URL.
Security-Scoped Bookmarks
On macOS, apps require explicit permission to access user files. r2Vault uses security-scoped bookmarks to maintain access to files across background tasks:AppViewModel.swift:435-446
AppViewModel.swift:518-533
This approach allows r2Vault to upload files even after the file picker dialog is closed, and supports cancellation and retry without requiring permission again.
Folder Uploads
When you upload a folder, r2Vault recursively enumerates all files and preserves the folder structure:AppViewModel.swift:371-403
MIME Type Detection
The upload system automatically detects the correct MIME type for each file:AppViewModel.swift:681-686
Content-Type header:
R2UploadService.swift:32
Correct MIME types ensure files are served with proper headers when accessed via their public URLs.
Error Handling
Upload failures are captured with detailed error messages:AppViewModel.swift:579-591
Related Features
File Browser
Upload files from the main browser interface
Menu Bar Widget
Quick uploads from the menu bar