The trait bound `Multipart: _::_serde::Deserialize<'_>` is not satisfied required by `next_element`


I have a form with a lot of data like name, address,... which I can successfully POST to Actix-web. But now I also want to mix a file into that form-data.

JQuery (Works fine):

    let file = $("#image")[0].files[0];
    let data = new FormData();
    data.append("name", $("#name").val());
    data.append("description", $("#description").val());;
    data.append("tel", $("#tel").val());
    data.append("email", $("#email").val());
    data.append("file", file);

        type: 'POST',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        url: url,
        success: function(response) {

This is my struct and here is the problem:

struct AddDistributorForm {
    name: String,
    description: String,
    tel: String,
    email: String,
    file: Multipart,

gives the following errors:

the trait bound `Multipart: _::_serde::Deserialize<'_>` is not satisfied required by `next_element`
the trait bound `Multipart: _::_serde::Deserialize<'_>` is not satisfied required by `next_value`

have already implemented
a file upload system in Rust
once, but then I was using the Multipart variable as a separated parameter and not mixed with other attributes in form-data.

How would I fix this?

Multipart is an Actix type and thus can't derive Deserialize. This can be fixed by using Multipart.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.