diff options
Diffstat (limited to 'src/file_upload.rs')
-rw-r--r-- | src/file_upload.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/file_upload.rs b/src/file_upload.rs index f72ab8b..c0ec95f 100644 --- a/src/file_upload.rs +++ b/src/file_upload.rs @@ -9,7 +9,8 @@ use std::{ path::{Component, PathBuf}, }; -pub fn save_file( +/// Create future to save file. +fn save_file( field: multipart::Field<dev::Payload>, file_path: PathBuf, ) -> Box<Future<Item = i64, Error = Error>> { @@ -30,7 +31,8 @@ pub fn save_file( ) } -pub fn handle_multipart( +/// Create new future to handle file as multipart data. +fn handle_multipart( item: multipart::MultipartItem<dev::Payload>, mut file_path: PathBuf, ) -> Box<Stream<Item = i64, Error = Error>> { @@ -65,6 +67,11 @@ pub fn handle_multipart( } } +/// Handle incoming request to upload file. +/// Target file path is expected as path parameter in URI and is interpreted as relative from +/// server root directory. Any path which will go outside of this directory is considered +/// invalid. +/// This method returns future. pub fn upload_file(req: &HttpRequest<crate::MiniserveConfig>) -> FutureResponse<HttpResponse> { if !req.query().contains_key("path") { return Box::new(future::ok( |