diff options
-rw-r--r-- | Cargo.lock | 82 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/errors.rs | 2 | ||||
-rw-r--r-- | src/file_op.rs | 4 |
4 files changed, 80 insertions, 10 deletions
@@ -94,20 +94,40 @@ dependencies = [ [[package]] name = "actix-multipart" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5011f5be460e35a5b82e1745c0ea0c6293e8f8d38bbaa1f0455afcff5b454ad6" +checksum = "3b960e2aea75f49c8f069108063d12a48d329fc8b60b786dfc7552a9d5918d2d" dependencies = [ + "actix-multipart-derive", "actix-utils", "actix-web", "bytes", "derive_more", "futures-core", + "futures-util", "httparse", "local-waker", "log", "memchr", "mime", + "serde", + "serde_json", + "serde_plain", + "tempfile", + "tokio", +] + +[[package]] +name = "actix-multipart-derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0a77f836d869f700e5b47ac7c3c8b9c8bc82e4aec861954c6198abee3ebd4d" +dependencies = [ + "darling 0.20.3", + "parse-size", + "proc-macro2", + "quote", + "syn 2.0.46", ] [[package]] @@ -800,8 +820,18 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core 0.20.3", + "darling_macro 0.20.3", ] [[package]] @@ -819,17 +849,42 @@ dependencies = [ ] [[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.46", +] + +[[package]] name = "darling_macro" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ - "darling_core", + "darling_core 0.14.4", "quote", "syn 1.0.109", ] [[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core 0.20.3", + "quote", + "syn 2.0.46", +] + +[[package]] name = "dary_heap" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -859,7 +914,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro2", "quote", "syn 1.0.109", @@ -1839,6 +1894,12 @@ dependencies = [ ] [[package]] +name = "parse-size" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944553dd59c802559559161f9816429058b869003836120e262e8caec061b7ae" + +[[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2377,6 +2438,15 @@ dependencies = [ ] [[package]] +name = "serde_plain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50" +dependencies = [ + "serde", +] + +[[package]] name = "serde_urlencoded" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -20,7 +20,7 @@ strip = true [dependencies] actix-files = "0.6" -actix-multipart = "0.5" +actix-multipart = "0.6" actix-web = { version = "4", features = ["macros", "compress-brotli", "compress-gzip", "compress-zstd"], default-features = false } actix-web-httpauth = "0.8" alphanumeric-sort = "1" diff --git a/src/errors.rs b/src/errors.rs index 6875b90..80d9b9e 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -18,7 +18,7 @@ pub enum ContextualError { /// Might occur during file upload, when processing the multipart request fails #[error("Failed to process multipart request\ncaused by: {0}")] - MultipartError(actix_multipart::MultipartError), + MultipartError(String), /// Might occur during file upload #[error("File already exists, and the overwrite_files option has not been set")] diff --git a/src/file_op.rs b/src/file_op.rs index d9786c4..590ab25 100644 --- a/src/file_op.rs +++ b/src/file_op.rs @@ -32,7 +32,7 @@ async fn save_file( })?; let (_, written_len) = field - .map_err(ContextualError::MultipartError) + .map_err(|x| ContextualError::MultipartError(x.to_string())) .try_fold((file, 0u64), |(mut file, written_len), bytes| async move { file.write_all(bytes.as_ref()) .map_err(|e| ContextualError::IoError("Failed to write to file".to_string(), e))?; @@ -209,7 +209,7 @@ pub async fn upload_file( }?; actix_multipart::Multipart::new(req.headers(), payload) - .map_err(ContextualError::MultipartError) + .map_err(|x| ContextualError::MultipartError(x.to_string())) .and_then(|field| { handle_multipart( field, |