How should I let some users to download from Private folder I stored the names of some users in one table and they should be able to download certain files from private folder(not other users). As i see i have to use hook_file_download

In the page of that hook it is said:


  If the user does not have permission to access the file, return -1. If
  the user has permission, return an array with the appropriate headers.


I don't understand which array should be returned exactly! my file in private folder is mp4 file and user has to see save page.
some users  file_create_url() but i don't know how to use it inside hook_file_download. can u give me one example code?

thanks in advanced for your help

edit: I found this code here:

  if ($can_access_file) {
    $headers = file_get_content_headers($file);
    return $headers;
  }  


I don't know exactly how to provide with $file! 
here is file_get_content_headers help
What field type serve the link for the download ? Maybe the module behind this type already implement this hook ?
For example, File module or Image module already implement this hook_file_download.

In case of File module, it allow you to alter the permission to access to the file. 

// Allow other modules to alter the returned grants/denies.
    drupal_alter('file_download_access', $grants, $field_item, $entity_type, $entity);


You just have to implement the hook_file_download_access_alter. By the way, there is this other hook (hook_file_download_acces) you can may be try to hook.

Finally, if no one of this hooks can help you, so may be you have to use this hook_file_download. But I don't really know what is expecting as headers, but you can look at the hook in the Image module.

There, it get headers from others modules (may be you can just use this trick) :

// Check the permissions of the original to grant access to this image.
  $headers = module_invoke_all('file_download', $original_uri);


And just after that, it make its own headers :

return array(

      // Send headers describing the image's size, and MIME-type...
      'Content-Type' =&gt; $info['mime_type'],
      'Content-Length' =&gt; $info['file_size'],
      // By not explicitly setting them here, this uses normal Drupal // Expires, Cache-Control and ETag headers to prevent proxy or // browser caching of private images.
    );


Hoping that help :)