doido-storage 0.0.12

Attached-file storage — blobs, polymorphic attachments and pluggable services (disk, memory, S3, Cloudflare R2, Azure Blob) in ActiveStorage fashion for Doido.
Documentation

doido-storage

Attached-file storage for the Doido framework — the ActiveStorage analogue.

It stores file bytes through a pluggable [Service] (disk by default, plus in-memory, S3, Cloudflare R2 and Azure Blob behind features) and keeps metadata (blobs, polymorphic attachments, variant records) in the database. The [Storage] facade ties a service, a connection and a [Signer] together and offers Rails-like operations; [serving::routes] mounts the blob-serving and direct-upload endpoints on axum.

# async fn demo(conn: doido_model::sea_orm::DatabaseConnection) -> doido_core::Result<()> {
use doido_storage::{Storage, MemoryService, Signer};
use std::sync::Arc;

let storage = Storage::new(conn, Arc::new(MemoryService::default()), Signer::from_env());
storage.ensure_tables().await?;
let blob = storage.create_and_upload("hello.txt", b"hi".to_vec(), None).await?;
let bytes = storage.download(&blob.key).await?;
assert_eq!(bytes, b"hi");
# Ok(()) }