pub struct StorageConfig {
pub default: String,
pub disks: HashMap<String, DiskConfig>,
}Expand description
Configuration for the storage system.
Fields§
§default: StringDefault disk name.
disks: HashMap<String, DiskConfig>Disk configurations.
Implementations§
Source§impl StorageConfig
impl StorageConfig
Sourcepub fn new(default: impl Into<String>) -> Self
pub fn new(default: impl Into<String>) -> Self
Create a new storage config with a default disk.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create configuration from environment variables.
Reads the following environment variables:
FILESYSTEM_DISK: Default disk name (default: “local”)FILESYSTEM_LOCAL_ROOT: Root path for local disk (default: “./storage”)FILESYSTEM_LOCAL_URL: Public URL for local filesFILESYSTEM_PUBLIC_ROOT: Root path for public disk (default: “./storage/public”)FILESYSTEM_PUBLIC_URL: Public URL for public files (default: “/storage”)
With s3 feature (provider-agnostic — works for any S3-compatible backend):
STORAGE_ACCESS_KEY_ID: access key (alias:AWS_ACCESS_KEY_ID, deprecated)STORAGE_SECRET_KEY: secret key (alias:AWS_SECRET_ACCESS_KEY, deprecated)STORAGE_REGION: region, default:"us-east-1"(alias:AWS_DEFAULT_REGION, deprecated)STORAGE_BUCKET: bucket name (alias:AWS_BUCKET, deprecated). When set, ans3disk is registered.STORAGE_PUBLIC_URL: public base URL for generated file URLs; overridesSTORAGE_ENDPOINTfor URL building (alias:AWS_PUBLIC_URL, deprecated)STORAGE_ENDPOINT: S3 API endpoint; also used as public URL base ifSTORAGE_PUBLIC_URLis not set (alias:AWS_URL, deprecated)CDN_URL: CDN base URL fronting the bucket (used bycdn_url()). Legacy aliasesAWS_CDN_URL,CF_CDN_URL, andBUNNY_CDN_URLare still accepted with a deprecation warning. Also readsCDN_PROVIDER/CDN_PURGE_TOKEN/CDN_PURGE_ZONEfor cache-invalidation configuration; seecrate::cdn::Config.
§Example
ⓘ
use ferro_storage::{StorageConfig, Storage};
let config = StorageConfig::from_env();
let storage = Storage::with_storage_config(config);Sourcepub fn disk(self, name: impl Into<String>, config: DiskConfig) -> Self
pub fn disk(self, name: impl Into<String>, config: DiskConfig) -> Self
Add a disk configuration.
Sourcepub fn default_disk(self, name: impl Into<String>) -> Self
pub fn default_disk(self, name: impl Into<String>) -> Self
Set the default disk.
Sourcepub fn get_default(&self) -> &str
pub fn get_default(&self) -> &str
Get the default disk name.
Sourcepub fn get_disk(&self, name: &str) -> Option<&DiskConfig>
pub fn get_disk(&self, name: &str) -> Option<&DiskConfig>
Get a disk configuration by name.
Trait Implementations§
Source§impl Clone for StorageConfig
impl Clone for StorageConfig
Source§fn clone(&self) -> StorageConfig
fn clone(&self) -> StorageConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StorageConfig
impl Debug for StorageConfig
Auto Trait Implementations§
impl Freeze for StorageConfig
impl RefUnwindSafe for StorageConfig
impl Send for StorageConfig
impl Sync for StorageConfig
impl Unpin for StorageConfig
impl UnsafeUnpin for StorageConfig
impl UnwindSafe for StorageConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more