Limit upload size to 64 KiB

Since that’s the limit of a TEXT column in MariaDB, and I don’t want to
deal with blobs.
This commit is contained in:
kageru 2019-09-29 11:59:24 +02:00
parent ede3297808
commit 5a5084c711
2 changed files with 4 additions and 4 deletions

@ -85,9 +85,9 @@ object Routes {
respond(HttpStatusCode.BadRequest, "Empty pastes are not allowed") respond(HttpStatusCode.BadRequest, "Empty pastes are not allowed")
return null return null
} }
if (content.length > 1024 * 1024) { if (content.length > 65535) {
Log.info("Rejecting paste over 1MB") Log.info("Rejecting paste over 64k")
respond(HttpStatusCode.BadRequest, "Pastes are limited to 1MB each") respond(HttpStatusCode.BadRequest, "Pastes are limited to 64 KiB")
return null return null
} }
val uri = PasteDao.insert(Paste(content, DateTime.now(), Paste.randomUri())).data.uri val uri = PasteDao.insert(Paste(content, DateTime.now(), Paste.randomUri())).data.uri

@ -58,7 +58,7 @@ object AboutPage {
} }
h3 { +"Expiration & limits" } h3 { +"Expiration & limits" }
p { p {
+"All pastes are limited to 1 MiB, and empty pastes are rejected." +"All pastes are limited to 64 KiB, and empty pastes are rejected."
br br
+"Right now, pastes are not pruned or deleted at all. " +"Right now, pastes are not pruned or deleted at all. "
+"If more people start using this, I might add something that deletes unaccessed pastes after a few months. We’ll see." +"If more people start using this, I might add something that deletes unaccessed pastes after a few months. We’ll see."