Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list out all the files in the public/images directory in a Play Framework 2 Scala application?

I want to list out all the file names in the public/images directory for my Scala Play Framework 2 application so that the Play Application just lists those file names to the HTML page. How can this be done?

Is there a right way to access the public/images directory to read files or list the directory? I don't want to use absolute directory paths.

like image 785
Phil Avatar asked Oct 12 '12 12:10

Phil


1 Answers

There is method getFile(relateivePath: String): File on Play object and also in the Application class which returns file relative to application root directory. In your case:

Play.getFile("public/images")

return File object, which represent public/images/directory. You can call list or listFiles on it to get contents of the directory.

like image 189
4e6 Avatar answered Sep 20 '22 10:09

4e6