andev
08/02/2020, 1:06 PMget("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)
}