Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub committed Nov 7, 2023
1 parent 6c66fb6 commit 754dafe
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 43 deletions.
84 changes: 42 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/controller/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ring::digest::{Context, SHA1_FOR_LEGACY_USE_ONLY};
use serde::Deserialize;
use sled::Batch;
use tokio::fs;
use tracing::log::error;

#[derive(Deserialize)]
pub(crate) struct UploadPicParams {
Expand Down Expand Up @@ -167,7 +168,14 @@ pub(crate) async fn upload_post(
break;
}

let data = field.bytes().await.unwrap();
let data = match field.bytes().await {
Ok(data) => data,
Err(e) => {
error!("{:?}", e);
return Ok(e.into_response());
}
};

let image_format_detected = image::guess_format(&data)?;
let ext;
let img_data = match image_format_detected {
Expand Down

0 comments on commit 754dafe

Please sign in to comment.