Storage manager for handling file operations with redundancy and failover.
This module coordinates file storage across multiple buckets with automatic redundancy, failover, and variant generation.
Summary
Functions
Deletes a file from all storage buckets.
Checks if a file exists in any storage bucket.
Returns file access info based on bucket access_type.
Returns the local filesystem path for a file if stored locally.
Gets a public URL for a file from the highest priority bucket that has it.
Retrieves a file from storage with failover.
Stores a file across multiple buckets based on redundancy settings.
Functions
Deletes a file from all storage buckets.
Checks if a file exists in any storage bucket.
Returns file access info based on bucket access_type.
Determines how a file should be served based on its storage location:
- Local files are always served directly
- Remote files depend on bucket's access_type setting
Returns
{:local, path}- File is local, serve directly from filesystem{:redirect, url}- Redirect to public URL (for public buckets){:proxy, file_name}- Download and proxy through server (for private buckets){:error, :not_found}- File not found in any bucket
Returns the local filesystem path for a file if stored locally.
This function checks enabled buckets with "local" provider and returns the direct path to the file if it exists. This allows serving files directly without copying to a temp file first.
Returns
{:ok, path}- File exists at the local path{:error, :not_local}- No local bucket contains the file
Gets a public URL for a file from the highest priority bucket that has it.
Retrieves a file from storage with failover.
Tries each bucket in priority order until the file is found.
Stores a file across multiple buckets based on redundancy settings.
Options
:redundancy_copies- Number of copies to store (default: from settings):priority_buckets- List of specific bucket IDs to use (default: auto-select):force_bucket_ids- List of specific bucket IDs to use (overrides priority_buckets):generate_variants- Whether to generate variants (default: from settings)
Returns
{:ok, file_result}- File stored successfully with locations{:error, reason}- Failed to store file