'stream error: Handler dropped payload before reading EOF in Actix Rust

I have an app using Next.js (^12.0.10) and Actix (4.0.0-beta.10) in the Server. I want to send images, transformed into base64 format, to the server then decoded back to binary and to save them in the server.
Everything works fine when I send pictures less than 2MB approx, since even if the image is a few hundreds of bytes the base64 conversion increases the value a lot. If I send an image greater than that I get the following error:

[Error ] handler did not read whole payload and dispatcher could not drain read buf;
    return 500 and close connection
[Error] stream error: Handler dropped payload before reading EOF

In the rust server I made the next changes, since I thought it was a problem with the payload:

HttpServer::new(|| {
    App::new().app_data(web::PayloadConfig::new(50_242_880))
})
...

And in the client using axios (^0.24.0):

class NewUniversity {
    name: string;
    img_file: string;
    img_type: string;

    constructor(name: string, img_file: string, img_type: string ) {
        this.name = name;
        this.img_file = img_file;
        this.img_type = img_type; 
    }
}

async function addUniversity(data: NewUniversity): Promise<AxiosResponse<string>>{
    const url = `${backendsrc}/university`;
    // Default options are marked with *
    return axios.post(url,data, {
        maxBodyLength: 50_242_880 // 50MiB
    });
}

Still after those changes I keep receiving the same error. Do I need to send the base64 data from the images compressed and then have it decompressed in the server? or is there another method?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source