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::{
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()?;

View file

@ -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() {