By tomas.teicher on
I have implementation of hook_file_download for accessing private files but it is not called
I have this code
<?php
function mymodule_file_download($uri) {
watchdog('mymodule', 'hook file_download was called');
$file = db_query("SELECT * FROM {file_managed} WHERE (uri = :uri)", array(':uri' => $uri))->fetchObject();
/*$headers = array(
'Content-Type: application/pdf',
'Cache-Control' => 'private',
'Content-Length' => $file->filesize,
'Last-Modified' => $file->timestamp,
'Content-disposition: attachment'
);*/
$headers = file_get_content_headers($file);
return $headers;
}
?>
I have private file in my private folder /sites/default/private_files/myfolder/test.pdf
When I insert this URL in browser I got message 403 forbidden.
I have set private_files as private in administration what generates this .htaccess file:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Deny from all
Options None
Options +FollowSymLinks
I have also tried to comment the two Options lines
watchdog message is not saved, so I think the hook is not called.
Can anybody help what am I doing wrong?
Comments
Nobody has similar problem
Nobody has similar problem with hook_file_download? Am I calling file_get_content_headers function on right place?
thanks for any hint
Tomas
Hmmm...I don't know your
Hmmm...I don't know your experience level so forgive me if this is insulting...but is your module name actually called 'my module'? That's the only thing I can think of that would make a hook 'invisible.' (I'm assuming you've refreshed the registry.)
Btw, I found your post because I'm trying to get private_download to work.
Having the same problem,
any news on this?
cheers!