Allow uploading images up to 32 MiB

This commit is contained in:
Joscha 2024-03-09 23:15:48 +01:00
parent 74b0d25dfc
commit 929ebb84eb

View file

@ -1,5 +1,5 @@
use axum::{ use axum::{
extract::{Multipart, State}, extract::{DefaultBodyLimit, Multipart, State},
http::StatusCode, http::StatusCode,
routing::post, routing::post,
Form, Router, Form, Router,
@ -22,6 +22,7 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
.route("/text", post(post_text)) .route("/text", post(post_text))
.route("/image", post(post_image)) .route("/image", post(post_image))
.route("/chat_message", post(post_chat_message)) .route("/chat_message", post(post_chat_message))
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
.with_state(Server { tx }); .with_state(Server { tx });
let listener = TcpListener::bind(addr).await?; let listener = TcpListener::bind(addr).await?;