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

View File

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

View File

@ -58,7 +58,7 @@ object AboutPage {
}
h3 { +"Expiration & limits" }
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
+"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."