diff options
author | Vojtěch Pejša <vojtechpejsa7@gmail.com> | 2019-03-25 13:44:45 +0000 |
---|---|---|
committer | Vojtěch Pejša <vojtechpejsa7@gmail.com> | 2019-04-04 08:51:00 +0000 |
commit | 1e8783e23c3c5e64acc40464329b64e3de6e2a20 (patch) | |
tree | 8db4e59e27707902099bc72c8f9227ef31deaa97 /src/file_upload.rs | |
parent | Refactoring (diff) | |
download | miniserve-1e8783e23c3c5e64acc40464329b64e3de6e2a20.tar.gz miniserve-1e8783e23c3c5e64acc40464329b64e3de6e2a20.zip |
Document file upload.
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( |