Expand description
§Crypsol Storage
Multi-cloud storage library for Rust with image processing, validation, and thumbnail generation.
§Backends
| Feature | Backend | Presigned URLs |
|---|---|---|
s3 (default) | AWS S3, Cloudflare R2, MinIO | Yes |
gcs | Google Cloud Storage | No |
azure | Azure Blob Storage | No |
local | Local filesystem (dev/testing) | No |
§Quick start
use crypsol_storage::{S3Backend, StorageConfig, StorageService, ImageUploadConfig};
let backend = S3Backend::builder()
.region("us-east-1")
.bucket("my-bucket")
.credentials("AKID...", "secret...")
.build()?;
let service = StorageService::new(backend, StorageConfig::default());
// Upload an image with automatic thumbnail generation
let config = ImageUploadConfig::default();
let result = service
.upload_image_with_config(&image_bytes, "image/jpeg", &config)
.await?;
println!("Image: {}", result.url);
println!("Thumbnail: {}", result.thumbnail_url);See the README for full examples covering every backend and API method.
Re-exports§
pub use backends::s3::S3Backend;pub use backends::s3::S3BackendBuilder;pub use backends::gcs::GcsBackend;pub use backends::gcs::GcsBackendBuilder;pub use backends::gcs::GcsCredentials;pub use backends::azure::AzureBackend;pub use backends::azure::AzureBackendBuilder;pub use backends::local::LocalBackend;
Modules§
Structs§
- Download
Result - Result of downloading an object.
- File
Upload Result - Result of a generic file upload.
- Image
Upload Config - Configuration for image upload operations.
- Presigned
Upload Result - Result of a presigned upload URL generation.
- PutOptions
- Options for object upload.
- RawDownload
Result - Raw result from a storage backend
get_objectcall. - Storage
Config - Configuration for the
StorageService. - Storage
Service - High-level storage service that wraps a
StorageBackendand adds image processing, validation, atomic uploads, and download limits. - Upload
Result - Result of a successful image upload containing both URLs.
Enums§
- Error
- Custom error type for storage-related failures.
Constants§
- ALLOWED_
IMAGE_ TYPES - Allowed image MIME types for upload validation.
- MAX_
PRESIGN_ EXPIRY_ SECS - Maximum presigned URL expiry in seconds (7 days).
- PROFILE_
IMAGE_ SIZE - Profile image dimensions (full size).
- THUMBNAIL_
SIZE - Profile thumbnail dimensions.
Traits§
- Storage
Backend - Trait for storage backends.
Functions§
- generate_
storage_ key - Generates a unique storage key.
Format:
{folder}/{YYYY/MM/DD}/{uuid}.{extension} - generate_
thumbnail_ key - Generates the thumbnail key from the main image key.
- validate_
content_ type - Validates the content type against allowed image types.
- validate_
expiry - Validates presigned URL expiry is within the 7-day limit.
- validate_
file_ size - Validates the file size against the provided maximum.