Expand description
§Ferro Storage
File storage abstraction for the Ferro framework.
Provides a unified API for working with different storage backends:
- Local filesystem
- In-memory (for testing)
- Amazon S3 (with
s3feature)
§Example
ⓘ
use ferro_storage::{Storage, DiskConfig};
// Create storage with configuration
let storage = Storage::with_config(
"local",
vec![
("local", DiskConfig::local("storage/app")),
("public", DiskConfig::local("storage/public").with_url("/storage")),
],
);
// Store a file
storage.put("documents/report.pdf", file_contents).await?;
// Get a file
let contents = storage.get("documents/report.pdf").await?;
// Get URL
let url = storage.disk("public")?.url("images/logo.png").await?;§Multiple Disks
You can configure multiple disks and switch between them:
ⓘ
use ferro_storage::Storage;
// Use specific disk
let disk = storage.disk("s3")?;
disk.put("backups/data.json", data).await?;
// Use default disk
storage.put("temp/cache.txt", cache_data).await?;Structs§
- Bytes
- Re-export bytes for convenience. A cheaply cloneable and sliceable chunk of contiguous memory.
- Disk
- A handle to a specific disk.
- Disk
Config - Storage disk configuration.
- File
Metadata - File metadata.
- Local
Driver - Local filesystem storage driver.
- Memory
Driver - In-memory storage driver.
- PutOptions
- Options for storing files.
- Storage
- Storage facade for file operations.
- Storage
Config - Configuration for the storage system.
Enums§
- Disk
Driver - Available disk drivers.
- Error
- Storage error types.
- Visibility
- Visibility of stored files.
Traits§
- Storage
Driver - Storage driver trait.
Attribute Macros§
- async_
trait - Re-export async_trait for implementing StorageDriver.