Fix again

This commit is contained in:
Citlali del Rey 2023-02-06 21:32:24 -08:00
parent d0b6bbc441
commit a2021eb363
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
1 changed files with 12 additions and 3 deletions

View File

@ -172,6 +172,11 @@ sub del_pin($c) {
}
sub upload_post($c) {
# Immediate check for size limit
if ($c->req->is_limit_exceeded) {
return $c->render(text => "Max file size reached.", status => 413);
}
if (!IpfsUpload::Util::check_auth($c)) {
return $c->redirect_to("/login");
}
@ -191,9 +196,13 @@ sub upload_post($c) {
return $c->redirect_to('/my');
}
if ($c->req->is_limit_exceeded || $file->size > $max_size) {
$c->flash(msg => "Max file size reached.");
return $c->redirect_to('/my');
if ($file->size > $max_size) {
if ($is_browser) {
$c->flash(msg => "Max file size reached.");
return $c->redirect_to('/my');
} else {
return $c->render(text => "Max file size reached.", status => 413);
}
}
# TODO: streaming somehow