Check if direct access to action


How can i determine whether a controller action is accessed directly from the browser?

I have an action used to serve files and images, and i need to add a permissions check when the user is directly accessing the url.

The same action can be called from some other actions / models / views, to display images etc., and in that case there’s no need to check for permissions.

How do i check if the action is called directly from an url or is called for example by an image src? (i don’t need to know what calls it, just if it’s called directly from the user or not)