pub struct Attachment {
pub key: String,
pub filename: String,
pub content_type: String,
pub size: u64,
}Available on crate features
storage-azure or storage-gcs or storage-local or storage-s3 only.Expand description
A stored file’s description. See the module docs.
Fields§
§key: StringWhere the bytes are in the storage backend.
filename: StringThe original file name, as uploaded.
content_type: String§size: u64Bytes.
Implementations§
Source§impl Attachment
impl Attachment
Sourcepub fn store(
storage: &dyn Storage,
prefix: &str,
filename: &str,
content_type: &str,
data: &[u8],
) -> Result<Attachment, StorageError>
pub fn store( storage: &dyn Storage, prefix: &str, filename: &str, content_type: &str, data: &[u8], ) -> Result<Attachment, StorageError>
Store data under a new key below prefix.
Sourcepub fn store_stream(
storage: &dyn Storage,
prefix: &str,
filename: &str,
content_type: &str,
reader: &mut dyn Read,
) -> Result<Attachment, StorageError>
pub fn store_stream( storage: &dyn Storage, prefix: &str, filename: &str, content_type: &str, reader: &mut dyn Read, ) -> Result<Attachment, StorageError>
Store everything reader yields (a streamed upload) under a new key
below prefix; the size is counted as it’s read.
Sourcepub fn from_multipart(
storage: &dyn Storage,
prefix: &str,
request: &Request,
field: &str,
) -> Result<Option<Attachment>, StorageError>
pub fn from_multipart( storage: &dyn Storage, prefix: &str, request: &Request, field: &str, ) -> Result<Option<Attachment>, StorageError>
Store the file uploaded in the multipart/form-data field field
of request. Ok(None) when the request has no such field or it
carries no file (no file name: an empty file input); Err for a body that isn’t
multipart/form-data.
Sourcepub fn url(&self, storage: &dyn Storage) -> String
pub fn url(&self, storage: &dyn Storage) -> String
The file’s URL (Storage::url).
Trait Implementations§
Source§impl Clone for Attachment
impl Clone for Attachment
Source§impl Debug for Attachment
impl Debug for Attachment
impl Eq for Attachment
Source§impl FromColumn for Attachment
Available on crate features model-mysql or model-postgres or model-sqlite only.
impl FromColumn for Attachment
Available on crate features
model-mysql or model-postgres or model-sqlite only.Source§impl PartialEq for Attachment
impl PartialEq for Attachment
impl StructuralPartialEq for Attachment
Auto Trait Implementations§
impl Forget for Attachment
impl Freeze for Attachment
impl Move for Attachment
impl RefUnwindSafe for Attachment
impl Send for Attachment
impl Sync for Attachment
impl Unpin for Attachment
impl UnsafeUnpin for Attachment
impl UnwindSafe for Attachment
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
Converts
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> ⓘ
Converts
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,
Available on crate feature
map-response-body only.Apply a transformation to the response body. Read more
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,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
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,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more