Actix-web Multipart form_data testing

⚓ Rust    📅 2025-09-26    👤 surdeus    👁️ 6      

surdeus

Warning

This post was published 35 days ago. The information described in this article may have changed.

Hi,

I am trying to use the basic example to upload a file and some json value (In the example, there is only one name value, but I intend to add more data in futur).

This is the basic source code : actix_multipart - Rust

So, in mine I have this :


#[derive(Debug, Deserialize)]
struct Metadata {
    name: String,
}

#[derive(Debug, MultipartForm)]
struct UploadForm {
    #[multipart(limit = "200MB")]
    file: TempFile,
    json: MpJson<Metadata>,
}

#[post("/api/test")]
pub async fn handler(MultipartForm(form): MultipartForm<UploadForm>) -> impl Responder {
    format!(
        "name {} , with size: {}",
        form.json.name, form.file.size
    )
}

I would like to test it in order to add other functionnalities after but the curl command does not works... Maybe I make a mistake, but I just copy it and change url, etc...
I would like also to test it with Postman for exemple.
But each time json value is not valid. I think it is not a rust problem, but as I need to test my functionnalities... I do not know what is wrong with my json...

image

I this as the file body is in file key, I can give the name I want to the file in json...

3 posts - 3 participants

Read full topic

🏷️ Rust_feed