https://kotlinlang.org logo
Title
a

andylamax

09/07/2020, 2:18 PM
How do I serve folders (not files) using ktor? I wan't to expose a certain directory that can be traversed in the browser via ktor. Solutions?
d

diesieben07

09/07/2020, 2:19 PM
This sounds like what you need: https://ktor.io/samples/other/filelisting.html
j

jorge.rego

09/07/2020, 2:21 PM
With this I can serve all the files as static references. But you may want to list files. Is that your question?
a

andylamax

09/07/2020, 2:23 PM
I need what @diesieben07 suggests. But it seems like a lot of work for something so trivial
if I could serve a directory tree (with subfolders with files), that would help a bunch
@jorge.rego I tried that approach. It only seems to serve files, not folders with there subfolders. Any other decen way you know?
j

jorge.rego

09/07/2020, 2:27 PM
Nop, sorry. You can always encapsulate the file listing example that Take mentioned. Will take you 5 minutes defining a FileProvider to feed the route definition.