Hello friends, Do anyone know how can I load file...
# server
p
Hello friends, Do anyone know how can I load file which is there in resource folder in ktor?
r
the good ol’ read-a-resource-file-from-JVM-resources way:
Copy code
class Helper

fun readFile(name: String): String =
    Helper::class.java.getResource(name)?.readText() ?: throw Exception("Could not find file $name")
However, you might want to look at ktor’s docs on serving static content @ https://ktor.io/docs/serving-static-content.html#resources
p
Thanks Ryan 👍