doido_storage/lib.rs
1//! # doido-storage
2//!
3//! Attached-file storage for the Doido framework — the ActiveStorage analogue.
4//!
5//! It stores file bytes through a pluggable [`Service`] (disk by default, plus
6//! in-memory, S3, Cloudflare R2 and Azure Blob behind features) and keeps
7//! metadata (blobs, polymorphic attachments, variant records) in the database.
8//! The [`Storage`] facade ties a service, a connection and a [`Signer`] together
9//! and offers Rails-like operations; [`serving::routes`] mounts the blob-serving
10//! and direct-upload endpoints on axum.
11//!
12//! ```no_run
13//! # async fn demo(conn: doido_model::sea_orm::DatabaseConnection) -> doido_core::Result<()> {
14//! use doido_storage::{Storage, MemoryService, Signer};
15//! use std::sync::Arc;
16//!
17//! let storage = Storage::new(conn, Arc::new(MemoryService::default()), Signer::from_env());
18//! storage.ensure_tables().await?;
19//! let blob = storage.create_and_upload("hello.txt", b"hi".to_vec(), None).await?;
20//! let bytes = storage.download(&blob.key).await?;
21//! assert_eq!(bytes, b"hi");
22//! # Ok(()) }
23//! ```
24
25pub mod attachments;
26pub mod blob;
27pub mod checksum;
28pub mod client;
29pub mod config;
30pub mod content_type;
31pub mod error;
32pub mod providers;
33pub mod registry;
34pub mod schema;
35pub mod service;
36pub mod serving;
37pub mod signing;
38
39#[cfg(feature = "storage-image")]
40pub mod analyzer;
41#[cfg(feature = "storage-jobs")]
42pub mod jobs;
43
44pub use blob::Blob;
45pub use client::Storage;
46pub use config::{ServiceBackend, ServiceConfig, StorageConfig};
47pub use error::StorageError;
48pub use providers::disk::DiskService;
49pub use providers::memory::MemoryService;
50pub use registry::{register_adapter, registered_adapters, ServiceFactory};
51pub use schema::ensure_tables;
52pub use service::{Service, UrlOptions};
53pub use signing::{Disposition, Signer};
54
55#[cfg(feature = "storage-azure")]
56pub use providers::azure::AzureBlobService;
57#[cfg(feature = "storage-gcs")]
58pub use providers::gcs::GcsService;
59#[cfg(feature = "storage-s3")]
60pub use providers::s3::S3Service;