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

rcd27

02/21/2022, 5:51 AM
Greetings, I'm trying to serve static files (from resources folder), it works properly according to the (guide)[https://ktor.io/docs/serving-static-content.html#defining-a-default-resource]. However, the filename is changed to
download
and I would like to keep the original one.
Copy code
routing {
        static("/download") {
            defaultResource("distributive/loottherun-desktop-0.10.29.zip")
        }
    }
So when I go to
localhost:8080/download
I see that browser "downloads"
download
file. It is the same as my zip, but naming is wrong. How I can keep the right naming? Tried to play around arguments in defaultResource method, but didn't work.
a

Aleksei Tirman [JB]

02/21/2022, 10:41 AM
You can either change the `static`'s route path to
/download/loottherun-desktop-0.10.29.zip
or serve all resource from a desired package
Copy code
static("/assets") {
    resources("distributive")
}
r

rnett

02/21/2022, 4:28 PM
Is there a way to do that even while hosting it at
/download
? I.e. using the
Content-Disposition
header
a

Aleksei Tirman [JB]

02/22/2022, 2:05 PM
With the
defaultResource
, no.
4 Views