Struct multipart::server::Multipart
[−]
[src]
pub struct Multipart<R> { pub save_dir: PathBuf, // some fields omitted }
The server-side implementation of multipart/form-data
requests.
Implements Borrow<R>
to allow access to the request object.
Fields
save_dir: PathBuf
The directory for saving files in this request.
By default, this is set to a subdirectory of std::env::temp_dir()
with a
random alphanumeric name.
Methods
impl<R> Multipart<R> where R: HttpRequest
[src]
fn from_request(req: R) -> Result<Multipart<R>, R>
If the given R: HttpRequest
is a POST request of Content-Type: multipart/form-data
,
return the wrapped request as Ok(Multipart<R>)
, otherwise Err(R)
.
fn read_entry(&mut self) -> Result<Option<MultipartField<R>>>
Read the next entry from this multipart request, returning a struct with the field's name and
data. See MultipartField
for more info.
Warning: Risk of Data Loss
If the previously returned entry had contents of type MultipartField::File
,
calling this again will discard any unread contents of that entry.
fn foreach_entry<F>(&mut self, foreach: F) -> Result<()> where F: FnMut(MultipartField<R>)
Call f
for each entry in the multipart request.
This is a substitute for Rust not supporting streaming iterators (where the return value
from next()
borrows the iterator for a bound lifetime).
Returns Ok(())
when all fields have been read, or the first error.
fn save_all(&mut self) -> (Entries, Option<Error>)
Read the request fully, parsing all fields and saving all files in self.save_dir
.
If there is an error in reading the request, returns the partial result along with the error.