Is there an easy/build-in way to have a controller check if a connection is authorized to access a static file not the server (with the use of a DB lookup) and then provide access if needed.
There are large video files, and I want a) check if the user is allowed to access the file, and b) if the user is authorized I want to record that the video has been watched.
There are two ways of doing this.
The first and most elegant way of doing it would be using the Play Plugin feature.
You can find more info at How to extend the playframework?
Here is the javadoc:
http://www.playframework.org/documentation/api/1.2.3/play/PlayPlugin.html
The second would be to serve the files from a route
If the files are route/controller based then you can just protect them like you would any other controller. Someone correct me if I’m wrong.
I would do something like (note this code has not been tested):
protect with
@With(Secure.class)Then the route
Or you could make it more elegant.
and
Or take it further.
Obviously you would need some trys and catches in there if the file didn’t exist.
Good luck.