Skip to main content

Module storage

Module storage 

Source
Expand description

§modo::storage

S3-compatible object storage.

This module provides Storage, a thin facade over S3-compatible backends (AWS S3, RustFS, MinIO, etc.). Features include upload from bytes or URL, presigned URLs, configurable ACLs, and file-size limits.

§Provides

TypePurpose
StorageSingle-bucket handle — upload, delete, public URL, presigned URL
BucketsNamed collection of Storage instances for multi-bucket apps
PutInputInput for Storage::put() / Storage::put_with()
PutFromUrlInputInput for Storage::put_from_url() / Storage::put_from_url_with()
PutOptionsOptional headers and ACL override for uploads
AclAccess control: Private (default) or PublicRead
BucketConfigDeserialisable configuration for one bucket
kb() / mb() / gb()Size-unit helpers (bytes conversion)

Use Storage::with_client() to share a reqwest::Client connection pool across multiple Storage instances or other modules.

§Quick start

use modo::storage::{BucketConfig, Storage, PutInput};

let mut config = BucketConfig::default();
config.bucket = "my-bucket".into();
config.endpoint = "https://s3.amazonaws.com".into();
config.access_key = "AKIAIOSFODNN7EXAMPLE".into();
config.secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY".into();
config.region = Some("us-east-1".into());
config.public_url = Some("https://cdn.example.com".into());
config.max_file_size = Some("10mb".into());
let storage = Storage::new(&config)?;

§Request signing

All requests are signed with AWS Signature Version 4. Both path-style (https://endpoint/bucket/key) and virtual-hosted-style (https://bucket.endpoint/key) URLs are supported via the path_style field in BucketConfig.

Structs§

BucketConfig
Configuration for a single S3-compatible storage bucket.
Buckets
Named collection of Storage instances for multi-bucket apps.
PutFromUrlInput
Input for Storage::put_from_url() and Storage::put_from_url_with().
PutInput
Input for Storage::put() and Storage::put_with().
PutOptions
Options for Storage::put_with() and Storage::put_from_url_with().
Storage
S3-compatible file storage.

Enums§

Acl
Access control for uploaded objects.

Functions§

gb
Convert gigabytes to bytes.
kb
Convert kilobytes to bytes.
mb
Convert megabytes to bytes.