pub struct LocalStorage { /* private fields */ }storage-azure or storage-gcs or storage-local or storage-s3 only.Expand description
Stores objects as files under a root directory on local disk.
Keys are treated as relative paths under root; parent directories are
created automatically on put. A key containing a .. segment is
rejected to prevent escaping root — the same defense used by the
config-driven proxy’s static-file action.
Content type is not persisted — plain files on disk have no metadata
slot for it. Pair this with a static-file route (which detects MIME type
from the file extension) if you need to serve uploaded files back over
HTTP; see with_base_url.
Implementations§
Source§impl LocalStorage
impl LocalStorage
Sourcepub fn new(root: impl Into<String>) -> LocalStorage
pub fn new(root: impl Into<String>) -> LocalStorage
Create a store rooted at root. The directory itself does not need
to exist yet — it (and any key subdirectories) are created on put.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> LocalStorage
pub fn with_base_url(self, base_url: impl Into<String>) -> LocalStorage
Set the URL prefix returned by Storage::url — e.g. /uploads if
root is also served as a static directory under that path. Without
a base URL, url() falls back to the object’s filesystem path.
Trait Implementations§
Source§impl Storage for LocalStorage
impl Storage for LocalStorage
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>
Writes to a temporary file beside the target as it reads, then renames it into place: a failed or partial upload never replaces an existing object.
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 LocalStorage
impl RefUnwindSafe for LocalStorage
impl Send for LocalStorage
impl Sync for LocalStorage
impl Unpin for LocalStorage
impl UnsafeUnpin for LocalStorage
impl UnwindSafe for LocalStorage
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.