Private files not fully supported : "upload_preview_file_download" missing
toeofdestiny - February 22, 2007 - 22:12
| Project: | Upload previews |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Your module is really great. But there is a little something missing to make "private" previews working :
function upload_preview_file_download($file) {
$preview = file_create_path(variable_get('upload_preview_path', 'preview'));
$file_info = pathinfo(file_create_path($file));
if ($file_info['dirname'] == $preview) {
return array('Content-Type: image/' . $file_info['extension']);
}
}Otherwise, there is no module to give the headers and it results in a "Page not found".
An easy fix for a great module! :-) Thank you.

#1
I added a strtolower, it may be important :
function upload_preview_file_download($file) {$preview = file_create_path(variable_get('upload_preview_path', 'preview'));
$file_info = pathinfo(file_create_path($file));
if ($file_info['dirname'] == $preview) {
return array('Content-Type: image/' . strtolower($file_info['extension']));
}
}
#2
Wow, thank you! I have updated the module to support private file systems. I did not release a new version. To get the new feature, please download the nightly tarball from http://drupal.org/node/109067.
#3