This commit is contained in:
Julian 2023-03-04 22:34:40 -05:00
parent 92e2dd410f
commit 6f12373923
Signed by: NotNite
GPG key ID: BD91A5402CCEB08A
2 changed files with 6 additions and 6 deletions

View file

@ -1,4 +1,5 @@
use axum::{ use axum::{
extract::DefaultBodyLimit,
routing::{delete, get, post}, routing::{delete, get, post},
Router, Server, Router, Server,
}; };
@ -41,6 +42,7 @@ async fn main() -> anyhow::Result<()> {
.route("/i/:id", delete(routes::delete)) .route("/i/:id", delete(routes::delete))
.route("/api/upload", post(routes::upload)) .route("/api/upload", post(routes::upload))
.route("/api/new_key", post(routes::new_key)) .route("/api/new_key", post(routes::new_key))
.layer(DefaultBodyLimit::max(1_000_000_000))
.with_state(Arc::clone(&state)); .with_state(Arc::clone(&state));
let addr: SocketAddr = format!("0.0.0.0:{}", port).parse()?; let addr: SocketAddr = format!("0.0.0.0:{}", port).parse()?;

View file

@ -21,12 +21,10 @@ pub async fn post(
let mut file = None; let mut file = None;
while let Some(field) = multipart.next_field().await.unwrap() { while let Some(field) = multipart.next_field().await.unwrap() {
file = Some( let bytes = field.bytes().await;
field if bytes.is_ok() {
.bytes() file = Some(bytes.unwrap());
.await }
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?,
);
} }
if file.is_none() { if file.is_none() {