1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # Garage SDK
//!
//! An async SDK for Garage (S3-compatible) that uploads files from paths, URLs,
//! or bytes and returns a stable public URL for CDN or proxy-fronted access.
//!
//! ## Features
//!
//! - Upload files from local paths, URLs, or raw bytes
//! - Automatic content-type detection
//! - Configurable key prefixes and file naming
//! - Proper error handling with detailed error types
//! - Builder pattern for flexible configuration
//!
//! ## Example
//!
//! ```rust,no_run
//! use garage_sdk::{GarageUploader, UploaderConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), garage_sdk::Error> {
//! let config = UploaderConfig::builder()
//! .endpoint("https://s3.example.com")
//! .bucket("my-bucket")
//! .public_base_url("https://cdn.example.com")
//! .credentials("access_key", "secret_key")
//! .build()?;
//!
//! let uploader = GarageUploader::new(config)?;
//!
//! let result = uploader.upload_from_path("./image.png").await?;
//! println!("Uploaded to: {}", result.public_url);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Download Buffering vs Streaming
//!
//! `upload_from_url` buffers small downloads in memory and streams larger or
//! unknown-size responses to avoid unbounded memory usage.
//!
//! - Default buffer threshold: 8 MB (`max_buffered_bytes`)
//! - Hard size limit: 100 MB (`max_file_size`)
//!
//! If `Content-Length` is present and below the threshold, the response is
//! buffered. Otherwise, the response is streamed and the size cap is enforced
//! during the read.
//!
//! ## Configuration Sources
//!
//! - Environment variables: `UploaderConfig::from_env()`
//! - Secret files directory: `UploaderConfig::from_secret_dir(...)`
//! - Env with file fallback: `UploaderConfig::from_env_or_secret_dir(...)`
//!
//! For Kubernetes env injection, set:
//! `GARAGE_ENDPOINT`, `GARAGE_BUCKET`, `GARAGE_PUBLIC_URL`,
//! `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
pub use aws_sdk_s3;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use UploadResult;
pub use GarageUploader;