Overview
QuickLookCoordinator manages the system Quick Look panel, allowing users to preview files directly from R2 storage without downloading them first. It streams files using presigned URLs and integrates with macOS’s native Quick Look functionality (spacebar preview).
Located at:
Fiaxe/Services/QuickLookCoordinator.swift:18Type Definition
Singleton Instance
Methods
preview()
Displays the Quick Look panel for a specific R2 object.The R2 object to preview. Must contain a valid key and name.
R2 credentials used to generate a presigned URL for secure access.
Implementation Details
- Gets the shared Quick Look panel
- Toggles panel visibility if already open for the same coordinator
- Generates a presigned URL for streaming the file directly from R2
- Wraps the URL in a
PreviewItemwith the filename for proper format detection - Sets itself as the data source and delegate
- Shows the panel and loads the preview
Preview Item Wrapper
The coordinator uses a privatePreviewItem class to wrap URLs for Quick Look:
The presigned URL pointing to the R2 object.
The original filename. Quick Look uses this to determine the correct previewer plugin based on file extension.
Why Wrap the URL?URL is a struct and can’t directly conform to the
QLPreviewItem protocol which requires NSObject. The wrapper class provides this conformance.Protocol Conformance
QLPreviewPanelDataSource
Provides preview items to the Quick Look panel.numberOfPreviewItems()
previewPanel(_:previewItemAt:)
QLPreviewPanelDelegate
Handles Quick Look panel events.previewPanel(_:handle:)
false to use default event handling. Could be customized for keyboard shortcuts or gestures.
Presigned URL Generation
The coordinator relies onAWSV4Signer to generate time-limited presigned URLs:
- Grant temporary read access to private R2 objects
- Expire after a set duration (typically 1 hour)
- Allow streaming without exposing credentials
- Work with any HTTP client (including Quick Look)
Supported File Types
Quick Look supports previews for many file types:Images
JPEG, PNG, GIF, HEIC, SVG, etc.
Videos
MP4, MOV, M4V, etc.
Documents
PDF, Pages, Word, Excel, etc.
Code
Swift, Python, JavaScript, etc.
Archives
ZIP, TAR, etc. (shows contents)
Audio
MP3, M4A, FLAC, etc.
Usage Example
Toggle Behavior
The coordinator implements smart toggle behavior:- Press spacebar to open preview
- Press spacebar again to close preview
- Switch between different files seamlessly
Integration with r2Vault
In the main browser view, Quick Look is triggered via:- Select a file and press spacebar
- Double-click a file (if implemented)
- See instant previews without downloading
Performance Characteristics
Streaming
Streaming
Files are streamed directly from R2 via presigned URLs. Quick Look handles buffering and caching automatically.
No Disk Usage
No Disk Usage
Previews don’t write to disk (unless Quick Look caches internally). Large files can be previewed without filling up storage.
Network Dependency
Network Dependency
Preview quality depends on network speed. Slow connections may show loading indicators.
Limitations
Security Considerations
Presigned URL SecurityPresigned URLs are temporary and scoped to a single object:
- URLs expire after a set duration (typically 1 hour)
- Each URL is signed with credentials
- URLs grant read-only access to one specific file
- No credentials are exposed to Quick Look or the user
- URLs can’t be used to access other files
Related Services
- AWSV4Signer - Generates presigned URLs
- R2BrowseService - Provides R2Object data
- ThumbnailCache - Generates list view thumbnails