Reputation: 6462
I would like to let two Play applications( deployed on the same server) to access a same folder, but I don't find the way to do it.
Is it possible to access a file by its absolute path, so I could put this folder at the directory level of my server and access it by the two applications?
Upvotes: 1
Views: 305
Reputation: 14825
Yes it is possible to access any folder given correct permissions to the play app process. You could access any file in the filesystem using Java file.
Ensure read write permissions accordingly if not Play throws FileNotFoundException
import java.io.File
@Singleton
class ApplicationController @Inject() () extends Controller {
def file = Action {
Ok.sendFile(new File(s"${sys.props("user.home")}/some_file.txt"))
}
}
In the above example some_file.txt
is send over http connection. Note that if permission are not correct then it will throw FileNotFoundException
Upvotes: 1