Skip to main content
The r2Vault upload system is built for speed and reliability, with support for concurrent uploads, per-file progress tracking, and automatic public URL generation.

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
The progress callback updates the UI in real-time:
AppViewModel.swift:545-555
Progress is calculated as bytesSent / totalBytes, displayed as a percentage in the UI.

Upload Task Model

Each upload is represented by a FileUploadTask 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
The upload service handles cancellation gracefully:
AppViewModel.swift:584-587
Cancelling an upload stops the transfer immediately. Partial data may be uploaded to R2 but will not be accessible.

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:
The URL format follows R2’s standard public URL pattern:
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
The bookmark is resolved when the upload actually runs:
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
Hidden files (those starting with .) are automatically skipped during folder uploads.

MIME Type Detection

The upload system automatically detects the correct MIME type for each file:
AppViewModel.swift:681-686
The MIME type is sent in the 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
Failed uploads remain in the queue with their error message visible. You’ll need to remove them manually or retry the operation.

File Browser

Upload files from the main browser interface

Menu Bar Widget

Quick uploads from the menu bar