I would create a custom page that handles that logic for you, either by getting the normal link to the file (if the file is stored in file systems), or if it's in the database, impersonate a "file access only" user and then continue them on to the main file.
So if the File is at A, your Custom page is at B, give the user a link to B which logs them in and redirects them to A.
Just one option.