URL to access a private file within Drupal 7 I want to be able to have my Drupal 7 site allow both public and private downloads (see below configuration screen shot).


  


It appears that the private directory at: sites/default/files/private is preventing direct access to the files which is what I want and is allowing direct public access to the files within: sites/default/files which is also what I want.

My question is what URL do I use to call the private files so that my function hook_file_download($url) it called and then can decide based on a combination of the directory within the /private directory and the requesting users role whether they have access to view this file?
The function you want to use is file_create_url().

You pass a stream wrapper path to your file, in this case it starts with 'private://'.

The value that you pass to the function is 'private://relative/path/to/file.txt'.

The relative path is based on the private files folder.