Creating Folders
Organize your R2 bucket by creating virtual folders:Folders in R2 are virtual — they’re represented by zero-byte objects with a trailing slash (e.g.,
photos/).BrowserView.swift:502-527 (source: Fiaxe/Views/BrowserView.swift:502-527)
Folder Naming Rules
- Must not be empty (after trimming whitespace)
- Can contain letters, numbers, hyphens, underscores
- Avoid special characters that require URL encoding
- The app automatically appends a trailing
/if needed
R2BrowseService.swift:88-110 (source: Fiaxe/Services/R2BrowseService.swift:88-110)
Deleting Files and Folders
Remove files and folders permanently from your R2 bucket.Delete a Single File
Delete Multiple Files (Batch Delete)
Use multi-select to delete several files at once:Select files
Click files one by one to add them to the selection, or use Select All from the toolbar
Batch deletions run concurrently for speed. Files and folders are deleted in parallel.
AppViewModel.swift:313-333 (source: Fiaxe/ViewModels/AppViewModel.swift:313-333)
Recursive Folder Deletion
Deleting a folder removes all files and subfolders inside it.How It Works
Recursive enumeration
r2Vault calls
listAllKeys() to get every object key under the folder prefix (no delimiter)- Recursive deletion logic:
AppViewModel.swift:336-347(source:Fiaxe/ViewModels/AppViewModel.swift:336-347) - List all keys:
R2BrowseService.swift:115-155(source:Fiaxe/Services/R2BrowseService.swift:115-155)
Example: Deleting a Nested Folder
vacation/ removes:
vacation/photos/beach.jpgvacation/photos/sunset.pngvacation/photos/family/group.jpgvacation/photos/family/kids.jpgvacation/videos/drone.mp4vacation/photos/family/(folder marker)vacation/photos/(folder marker)vacation/videos/(folder marker)vacation/(folder marker)
Presigned URL Generation
Generate temporary download URLs for private files.Presigned URLs allow read-only access to R2 objects for a limited time without exposing your credentials.
Generate a Presigned URL
Presigned URL Format
Generated URLs include AWS Signature V4 query parameters:Expiration time in seconds (default: 1 hour)
AWSV4Signer.swift (source: Fiaxe/Services/AWSV4Signer.swift)
Use Cases for Presigned URLs
Share privately
Share a file with someone without making the entire bucket public
Download from browser
Paste the URL in a browser to download the file directly
Embed in apps
Use in
<img> tags, <video> tags, or API responsesQuick Look preview
r2Vault uses presigned URLs to stream files for preview without local download
Public vs. Presigned URLs
| Type | When to Use | Example |
|---|---|---|
| Public URL | Custom domain configured, bucket is public | https://cdn.example.com/photo.jpg |
| Presigned URL | No custom domain, or bucket is private | https://abc.r2.cloudflarestorage.com/bucket/photo.jpg?X-Amz-... |
r2Vault auto-copies public URLs after upload if you have a custom domain configured. Use presigned URLs for secure, time-limited access.
File Operations Reference
Supported Operations
| Operation | Method | API Call |
|---|---|---|
| Create folder | PUT | PUT /<bucket>/<folder>/ with Content-Length: 0 |
| Delete file | DELETE | DELETE /<bucket>/<key> |
| Delete folder | DELETE (recursive) | List all keys with prefix, then batch DELETE |
| Generate presigned URL | Signature | AWS SigV4 with query parameters |
| Copy URL | Read-only | Constructs URL from credentials + key |
API Compatibility
r2Vault uses the S3-compatible API provided by Cloudflare R2:- Endpoint:
https://<account>.r2.cloudflarestorage.com - Authentication: AWS Signature Version 4 (HMAC-SHA256)
- Supported operations: GET, PUT, DELETE, HEAD, ListObjectsV2
R2BrowseService.swift(source:Fiaxe/Services/R2BrowseService.swift)R2UploadService.swift(source:Fiaxe/Services/R2UploadService.swift)AWSV4Signer.swift(source:Fiaxe/Services/AWSV4Signer.swift)