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

Alex Styl

12/11/2021, 4:25 PM
How can I check the size of an uploaded file to ktor? Checked the documentation and searched here but surprised I couldn’t find something
My use case was to prevent users from uploading too large files. I realized I can do this with nginx.
c

CLOVIS

12/12/2021, 10:17 AM
I'm interested in the same thing.
a

Aleksei Tirman [JB]

12/13/2021, 8:45 AM
You can get the number of bytes from the
Content-Length
header (if it's available) before receiving the body.
👍 1
c

CLOVIS

12/17/2021, 1:11 PM
That's a good first step, however the client could lie about it. If the client lies, will Ktor trust the value?
a

Aleksei Tirman [JB]

12/17/2021, 1:16 PM
What do you mean by trusting the value?