pub struct S3Storage { /* private fields */ }storage-azure or storage-gcs or storage-local or storage-s3 only.Expand description
S3-compatible object storage (AWS S3, Cloudflare R2, MinIO, …).
Signs every request with AWS Signature Version 4 using the outbound HTTP
client (crate::http_client::Client) — no AWS SDK dependency. Uses
path-style addressing ({endpoint}/{bucket}/{key}), which every
S3-compatible provider supports; virtual-hosted-style ({bucket}.{host})
is not used since custom endpoints for R2/MinIO don’t reliably support it.
Credentials come from config.access_key/config.secret_key when both
are non-empty; otherwise they’re auto-detected from EKS IRSA, ECS task
role, or EC2 IMDSv2 (in that order), cached, and refreshed shortly before
expiry. See crate::storage::aws_credentials.
Implementations§
Source§impl S3Storage
impl S3Storage
pub fn new(config: S3Config) -> S3Storage
Sourcepub fn with_ca_file(self, path: &str) -> Result<S3Storage, StorageError>
pub fn with_ca_file(self, path: &str) -> Result<S3Storage, StorageError>
Trust the CA certificates in the PEM file at path for an
https:// endpoint signed by a private CA, instead of the public
roots.
Sourcepub fn from_env() -> Result<S3Storage, StorageError>
pub fn from_env() -> Result<S3Storage, StorageError>
S3Storage::new(S3Config::from_env()?), with
with_ca_file when RWS_S3_CA_FILE is set.
Trait Implementations§
Source§impl Storage for S3Storage
impl Storage for S3Storage
Source§fn put_stream(
&self,
key: &str,
reader: &mut dyn Read,
content_type: &str,
) -> Result<String, StorageError>
fn put_stream( &self, key: &str, reader: &mut dyn Read, content_type: &str, ) -> Result<String, StorageError>
S3 multipart upload: parts of [S3_PART_SIZE] read and sent one at
a time, so memory stays at one part however large the object. An
object that fits in one part is a plain PUT. Any failure aborts the
upload, so S3 keeps no orphaned parts.
Source§fn put(
&self,
key: &str,
data: &[u8],
content_type: &str,
) -> Result<String, StorageError>
fn put( &self, key: &str, data: &[u8], content_type: &str, ) -> Result<String, StorageError>
data under key, overwriting any existing object at that key.
Returns the key that was stored (backends that normalize or namespace
keys may return a different string than the one passed in).Source§fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>
fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>
key.Auto Trait Implementations§
impl !Freeze for S3Storage
impl RefUnwindSafe for S3Storage
impl Send for S3Storage
impl Sync for S3Storage
impl Unpin for S3Storage
impl UnsafeUnpin for S3Storage
impl UnwindSafe for S3Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.