mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 20:09:48 -05:00
fix(upload): prevent sending zero bytes
This commit is contained in:
parent
f4a3c07def
commit
315a649777
1 changed files with 4 additions and 0 deletions
|
@ -56,6 +56,10 @@ async fn upload(
|
|||
return Err(error::ErrorPayloadTooLarge("upload limit exceeded"));
|
||||
}
|
||||
}
|
||||
if bytes.is_empty() {
|
||||
log::warn!("{} sent zero bytes", host);
|
||||
return Err(error::ErrorBadRequest("invalid file size"));
|
||||
}
|
||||
let bytes_unit = Byte::from_bytes(bytes.len() as u128).get_appropriate_unit(false);
|
||||
let file_name = &file::save(content.get_file_name()?, &bytes, &config)?;
|
||||
log::info!("{} ({}) is uploaded from {}", file_name, bytes_unit, host);
|
||||
|
|
Loading…
Reference in a new issue