I want to disable access to the view display page of file by url like file/fid.
What's the good way for this? I have tried to use the hook_node_view() but it not called for the files.
I have finally used the RABBIT HOLE module, it contains a sub-module for managing file_entity! :)
You can do this by using below ways :
Unpublish your node
Node Page Disable module
Allows easy UI access and disabling of the path /node when not used. This was inspired by a security consideration in the Production Check Module.
Have you ever used a slideshow nodetype that you need to be published but don't want the node be accessible by itself using then node/XXX path? This module is for you!
With this module you can disable direct access to node pages (node/XXX) based on nodetypes and permissions.
Enable the module and don't forget to configure your permissions.