diff --git a/.gitignore b/.gitignore index 8c38c0e..197e37a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/*.rs.bk Cargo.lock /examples/filename*.png +/.envrc +/.direnv diff --git a/Cargo.toml b/Cargo.toml index da86b16..64bdfa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "actix-form-data" description = "Multipart Form Data for Actix Web" -version = "0.7.0-beta.0" +version = "0.7.0-beta.1" license = "GPL-3.0" authors = ["asonix "] repository = "https://git.asonix.dog/asonix/actix-form-data.git" @@ -10,7 +10,7 @@ keywords = ["actix", "form-data", "multipart", "async"] edition = "2021" [dependencies] -actix-multipart = "0.4.0" +actix-multipart = { version = "0.6.0", default-features = false } actix-rt = "2.5.0" actix-web = { version = "4.0.0", default-features = false } futures-util = "0.3.17" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1e4bcf3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1685564631, + "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1426089 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + in + { + packages.default = pkgs.hello; + + devShell = with pkgs; mkShell { + nativeBuildInputs = [ cargo cargo-outdated cargo-zigbuild clippy gcc protobuf rust-analyzer rustc rustfmt ]; + + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + }; + + formatter = pkgs.nixpkgs-fmt; + }); +} diff --git a/src/types.rs b/src/types.rs index c5b11ab..e702296 100644 --- a/src/types.rs +++ b/src/types.rs @@ -32,7 +32,7 @@ use tracing::trace; #[derive(Debug)] pub struct FileMeta { pub filename: String, - pub content_type: Mime, + pub content_type: Option, pub result: T, } @@ -155,7 +155,7 @@ impl From> for Value { pub type FileFn = Box< dyn Fn( String, - Mime, + Option, Pin>>>, ) -> Pin>>> >; @@ -215,7 +215,7 @@ impl Field { /// ``` pub fn file(f: F) -> Self where - F: Fn(String, Mime, Pin>>>) -> Fut + F: Fn(String, Option, Pin>>>) -> Fut + Clone + 'static, Fut: Future> + 'static, @@ -437,8 +437,8 @@ impl Map { Some(NamePart::Map(name_part)) => self .inner .iter() - .find(|&&(ref item, _)| *item == *name_part) - .and_then(|&(_, ref field)| field.valid_field(name)), + .find(|(ref item, _)| *item == *name_part) + .and_then(|(_, ref field)| field.valid_field(name)), _ => None, } } diff --git a/src/upload.rs b/src/upload.rs index 8400701..8be60c0 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -117,7 +117,7 @@ where let file_size = Arc::new(AtomicUsize::new(0)); - let content_type = field.content_type().clone(); + let content_type = field.content_type().cloned(); let max_file_size = form.max_file_size;