URI Formats
Cloud Storage - Service-Native URIs
Cloud files use the same URI format as their native tools:{service}://{identifier}/{path}
Where:
{service}: Cloud service type (s3, gdrive, onedrive, dropbox, azblob, gcs, b2, wasabi, spaces){identifier}: Service-specific root (bucket name, folder, container){path}: Path within the service
Local Files - Device-Aware URIs
Local files include the device name for multi-device clarity:local://{device-slug}/{path}
Where:
{device-slug}: URL-safe device identifier (generated from device name){path}: Absolute path on that device
Device slugs are generated automatically from your device name by converting
to lowercase and replacing non-alphanumeric characters with hyphens. “Jamie’s
MacBook Pro” becomes
jamies-macbook-pro.Content-Addressed Files
Content URIs reference files by their content hash, independent of location:content://{uuid}
This enables location-independent operations. The same photo stored on multiple devices and in cloud storage shares one content URI. Spacedrive resolves it to the most efficient available location.
Device Slug System
Spacedrive generates URL-safe slugs from device names to create stable, human-readable URIs.Slug Generation
- “Jamie’s MacBook” →
jamies-macbook - “Home Server 2024” →
home-server-2024 - “DESKTOP-ABC123” →
desktop-abc123
Slug Uniqueness
Each device’s slug must be unique within your Spacedrive network. The database enforces this with a unique constraint on theslug column. If you try to add a device with a duplicate name, you’ll need to rename one device.
Resolution
When parsing alocal:// URI, Spacedrive looks up the device by slug:
How It Works
Spacedrive maintains user-friendly URIs in the display layer while using efficient internal identifiers for operations.User-Facing Display
Internal Representation
Resolution Flow
SdPath, making cloud paths self-contained. The VolumeManager maintains a mount point cache for fast volume lookups.
Cloud Service Schemes
Spacedrive supports these cloud URI schemes:
S3-compatible services (MinIO, Cloudflare R2, Wasabi, etc.) use the
s3:// scheme with custom endpoints.
Parsing URIs
From User Input
Error Handling
CLI Usage
The unified addressing scheme makes CLI operations intuitive:Code Examples
File Operations
Display Paths
Building Paths
Industry Standard Alignment
Spacedrive’s addressing matches industry tools: AWS CLI:Benefits
Self-Documenting
URIs clearly show where files live:Cross-Storage Operations
Operations work identically across storage types:Location Independence
Content URIs enable operations without knowing physical location:Limitations
Device Slug Resolution
Device slug resolution works for all devices in the library through an in-memory cache. When a library opens, all device slugs are loaded into the DeviceManager’s cache, enabling instant O(1) resolution for any device whether online or offline. The cache updates automatically when:- A library is opened (loads all devices from database)
- New devices pair and sync
- The library closes (cache is cleared)
local:// URIs can reference any device in the library, not just the current device.
Cloud Volume Lookup
Cloud volumes use an O(1) mount point cache for fast lookups. The cache maps mount point strings (e.g.,"s3://my-bucket") to volume fingerprints. For volumes added before the cache was implemented, a linear scan serves as a fallback.
Slug Collisions
If two devices would generate the same slug, the second device must be renamed. There’s no automatic disambiguation.Best Practices
URI Display
Usedisplay() to convert SdPath to a user-facing URI string. The method generates the appropriate format automatically based on the path type.
URI Parsing
Usefrom_uri() when parsing user input. The method parses service-native URIs and validates the format.
Device Naming
Choose distinct device names to avoid slug collisions. Include location or purpose in names:- “jamies-macbook-home”
- “jamies-macbook-work”
- “home-server-basement”
- “backup-nas-office”
Cloud Mount Points
Spacedrive ensures cloud mount points are unique by appending-2, -3 if collisions occur:
Related Documentation
- Devices - Device management and pairing
- Volumes - Volume system and cloud integration
- Cloud Integration - Cloud storage details
- Data Model - SdPath internal representation
