I'm not even doing anything complex, here's the sn...
# ktor
a
I'm not even doing anything complex, here's the snippet:
Copy code
get("files") {
    val filePath = call.request.queryParameters["path"]
    if (filePath == null) {
        call.respond(HttpStatusCode.NotFound)
        return@get
    }
    val file = File(filePath)
    if (!file.exists()) {
        call.respond(HttpStatusCode.NotFound)
        return@get
    }
    call.response.header(
        HttpHeaders.ContentDisposition,
        ContentDisposition.Attachment.withParameter(ContentDisposition.Parameters.FileName, file.name).toString()
    )
    call.respondFile(file)
}