My files are stored under uploads folder next to my fat jar server and files are getting saved there properly but while accessing these files over a cloud server http://{IP_ADDRESS}:8085/uploads/image1.png, I'm getting 404.
This works perfectly fine on my localhost.
//Directory structure
root@localhost:~/ktor# ls
build my-server.jar uploads
//Backend code
fun Application.configureRouting() {
routing {
staticRoutes()
}
}
fun Route.staticRoutes() {
val projectRoot = File(System.getProperty("user.dir"))
staticFiles("/uploads/", File("${projectRoot}\\uploads"))
}
Not sure what am I missing, any clue?
The problem is in the backslash path delimiter (
"${projectRoot}\\uploads"). The following code works as expected: