When I use this library and I try to upload a file larger than the default 256kb file limit, I get the following error:
Multipart error: Payload reached size limit.
This is the code I use for the endpoint:
#[derive(FromMultipart, ToSchema)]
struct Payload {
other: String,
#[schema(value_type = String, format = Binary)]
payload: File,
}
#[utoipa::path(
request_body(content = Payload, content_type = "multipart/form-data"),
responses(
(status = 201, description = "Payload successfully uploaded"),
)
)]
#[post("/payload/upload")]
async fn task_upload(metadata: MultipartForm<Payload>) -> impl Responder {
println!("{}, {:?}", metadata.other, metadata.payload.filename);
HttpResponse::Ok()
}
To fix this, I've tried to change the default size for both actix and this library:
HttpServer::new(move || {
App::new()
.app_data(state.clone())
.app_data(actix_web::web::PayloadConfig::new(500 * 1024 * 1024))
.app_data(MultipartFormConfig::default().file_limit(500 * 1024 * 1024))
.service(
SwaggerUi::new("/swagger-ui/{_:.*}").url("/api-doc/openapi.json", openapi.clone()),
)
.service(task_upload)
})
.bind(("0.0.0.0", 8080))?
.run()
.await
Nothing seems to help. When I use Multipart
and stream directly from actix, the file limit error does not kick in.
I'm not sure if the issue happens in this library, or if it is actix as this is unfortunately a part of the framework that lacks documentation.