diff --git a/server/src/main.rs b/server/src/main.rs index 29d2be0..647b793 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,4 +1,5 @@ use axum::{ + extract::DefaultBodyLimit, routing::{delete, get, post}, Router, Server, }; @@ -41,6 +42,7 @@ async fn main() -> anyhow::Result<()> { .route("/i/:id", delete(routes::delete)) .route("/api/upload", post(routes::upload)) .route("/api/new_key", post(routes::new_key)) + .layer(DefaultBodyLimit::max(1_000_000_000)) .with_state(Arc::clone(&state)); let addr: SocketAddr = format!("0.0.0.0:{}", port).parse()?; diff --git a/server/src/routes/upload.rs b/server/src/routes/upload.rs index 4ad679a..333ca2c 100644 --- a/server/src/routes/upload.rs +++ b/server/src/routes/upload.rs @@ -21,12 +21,10 @@ pub async fn post( let mut file = None; while let Some(field) = multipart.next_field().await.unwrap() { - file = Some( - field - .bytes() - .await - .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?, - ); + let bytes = field.bytes().await; + if bytes.is_ok() { + file = Some(bytes.unwrap()); + } } if file.is_none() {