From be81eaefa526fa80e04166e86978e3a95263b4e3 Mon Sep 17 00:00:00 2001 From: Alec Di Vito Date: Thu, 6 Jun 2024 18:42:20 -0400 Subject: feat: Added HTML and Javascript progress bar when uploading files --- src/config.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 3643502..6e8b89e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -101,6 +101,9 @@ pub struct MiniserveConfig { /// Enable file upload pub file_upload: bool, + /// Max amount of concurrency when uploading multiple files + pub web_upload_concurrency: usize, + /// List of allowed upload directories pub allowed_upload_dir: Vec, @@ -301,6 +304,7 @@ impl MiniserveConfig { show_qrcode: args.qrcode, mkdir_enabled: args.mkdir_enabled, file_upload: args.allowed_upload_dir.is_some(), + web_upload_concurrency: args.web_upload_concurrency, allowed_upload_dir, uploadable_media_type, tar_enabled: args.enable_tar, -- cgit v1.2.3 From 577044ddbd70f5f128512c1a021329fb4c7e7eb3 Mon Sep 17 00:00:00 2001 From: Alec Di Vito Date: Sat, 22 Feb 2025 13:44:16 -0500 Subject: feat: address comments; add in new argument (`temp-directory`); add comments to upload code; add tests --- src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 449d2ae..6a048c2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -33,6 +33,9 @@ pub struct MiniserveConfig { /// Path to be served by miniserve pub path: std::path::PathBuf, + /// Temporary directory that should be used when files are uploaded to the server + pub temp_upload_directory: Option, + /// Port on which miniserve will be listening pub port: u16, @@ -275,9 +278,16 @@ impl MiniserveConfig { .transpose()? .unwrap_or_default(); + let temp_upload_directory = args.temp_upload_directory.as_ref().take().map(|v| if v.exists() && v.is_dir() { + Ok(v.clone()) + } else { + Err(anyhow!("Upload temporary directory must exist and be a directory. Validate that path {v:?} meets those requirements")) + }).transpose()?; + Ok(Self { verbose: args.verbose, path: args.path.unwrap_or_else(|| PathBuf::from(".")), + temp_upload_directory, port, interfaces, auth, -- cgit v1.2.3 From 33c79837f1e113a1ce83a461413acf474e973c63 Mon Sep 17 00:00:00 2001 From: Alec Di Vito Date: Sun, 2 Mar 2025 14:46:10 -0500 Subject: feat: validate temp dir exists through `value_parser` and fixed clippy issues --- src/config.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 6a048c2..4404959 100644 --- a/src/config.rs +++ b/src/config.rs @@ -278,16 +278,10 @@ impl MiniserveConfig { .transpose()? .unwrap_or_default(); - let temp_upload_directory = args.temp_upload_directory.as_ref().take().map(|v| if v.exists() && v.is_dir() { - Ok(v.clone()) - } else { - Err(anyhow!("Upload temporary directory must exist and be a directory. Validate that path {v:?} meets those requirements")) - }).transpose()?; - Ok(Self { verbose: args.verbose, path: args.path.unwrap_or_else(|| PathBuf::from(".")), - temp_upload_directory, + temp_upload_directory: args.temp_upload_directory, port, interfaces, auth, -- cgit v1.2.3