https://kotlinlang.org logo
#ktor
Title
# ktor
a

Alex Styl

12/30/2021, 12:08 PM
How can I set the allowed upload size to ktor?
I ended up doing:
Copy code
val contentLength = call.request.headers["Content-Length"]?.toLong()
        if (contentLength == null) {
            call.respond(HttpStatusCode.LengthRequired)
        } else if (contentLength > MAX_SIZE) {
            call.respond(HttpStatusCode.PayloadTooLarge)
        }
works alright for my needs. Currently there is only one post request that accepts files so I am only doing it there.
4 Views