pub struct Upload {
pub filename: String,
pub content_type: String,
pub bytes: Bytes,
}Expand description
A file from a multipart form: its name on the client, its declared content type and its bytes.
Fields§
§filename: String§content_type: String§bytes: BytesImplementations§
Source§impl Upload
impl Upload
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn detected_type(&self) -> String
pub fn detected_type(&self) -> String
The file’s type as its bytes show it, the declared type aside, as
Paperclip’s detector stores it: the type its signature names
(image/png), else its extension’s, else text/plain for text and
application/octet-stream for anything else; inode/x-empty when
empty.
Sourcepub fn is_spoofed(&self) -> bool
pub fn is_spoofed(&self) -> bool
Whether the file isn’t what its declared type says, as Paperclip’s
spoof check: the declared kind (image of image/png) disagrees
with the extension’s (shelf.pdf) or with the bytes (text sent as
image/png). A Rails app’s message for it is “has contents that are
not what they are reported to be”.
Unlike file, it knows only common types: bytes it can’t name, and
extensions it doesn’t know, never count as a mismatch.
Trait Implementations§
impl Eq for Upload
impl StructuralPartialEq for Upload
Auto Trait Implementations§
impl !Freeze for Upload
impl RefUnwindSafe for Upload
impl Send for Upload
impl Sync for Upload
impl Unpin for Upload
impl UnsafeUnpin for Upload
impl UnwindSafe for Upload
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> 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§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
key and return true if they are equal.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 more