awmpde

Docs Crates.io

A convenience library for working with multipart/form-data in actix-web 3.x.

This library uses actix-multipart internally, and is not a replacement for actix-multipart.

Usage

This crate supports actix-web of versions 3.x only.

toml awmpde = "0.2.0"

Example

```rust use actix_web::{web, App, post, Error, HttpResponse, HttpServer}; use serde::Deserialize;

[derive(Deserialize, Debug)]

struct Description { genre: String, author: String, year: i64, }

[derive(FromActixMultipart)]

struct Book { file: awmpde::File>, #[serde_json] description: Description, }

[post("/put_book")]

async fn putbook(book: awmpde::Multipart) -> Result { let Book { file: awmpde::File { name, inner, ..}, description } = book.intoinner()?; std::fs::write(std::path::Path::from("books").join(name), &*inner)?; let body = format!("Wrote book with description {:?}", desription); Ok(HttpResponse::Ok().body(body)) }

[actix_rt::main]

async fn main() -> Result<(), std::io::Error> { actixweb::HttpServer::new(move || { actixweb::App::new() .route(put_book) }) .bind("0.0.0.0:3000")? .run() .await } ```

Current version: 0.2.0

License: MIT