pub struct Upload<H> { /* private fields */ }Expand description
A file a form submitted, with the caller’s handle for where its content was stored.
The parser does not keep an upload’s content: it reports the content to the caller as it arrives, and the caller stores it, such as in a temporary file, and gives the parser a handle of type H for it. The filename and media type are what the client declared, and must not be trusted: a filename can contain path separators, .., a tab, Unicode controls such as bidirectional overrides, and, decoded from filename* when ParameterRules::Mime apply, CR, LF, and NUL, and a media type need not describe the content. The parser never gives an upload with an empty filename, which means no file was chosen.
Implementations§
Source§impl<H> Upload<H>
impl<H> Upload<H>
Sourcepub fn new(
untrusted_filename: impl Into<String>,
untrusted_media_type: Option<MediaType>,
size: u64,
handle: H,
) -> Self
pub fn new( untrusted_filename: impl Into<String>, untrusted_media_type: Option<MediaType>, size: u64, handle: H, ) -> Self
An upload as the parser would give it, such as for an application’s own tests of what it does with its declared struct.
Sourcepub fn untrusted_filename(&self) -> &str
pub fn untrusted_filename(&self) -> &str
The filename the client declared, which the parser never gives empty, since an empty filename means no file was chosen. It can contain any character, as the type’s documentation describes, and must not be used as a local path, or written into another syntax, without checking or encoding it.
Sourcepub fn untrusted_media_type(&self) -> Option<&MediaType>
pub fn untrusted_media_type(&self) -> Option<&MediaType>
The media type the client declared for the content, if any, which need not describe the content.
Sourcepub fn into_handle(self) -> H
pub fn into_handle(self) -> H
The handle, taken from the upload.