You have a bug in your function filebrowser_page_download($fid) when the ZipArchive is created in the Default Temporary Folder :
$target = file_directory_temp() . "/filebrowser_" . _filebrowser_safe_basename($target) . ".zip";
By default, the return value by the function file_directory_temp (http://api.drupal.org/api/function/file_directory_temp/6) is the real path set in php.ini -> upload_tmp_dir OR by default /tmp
Which is incompatible with the Download Manager set to "Direct Download" because the archive is outside the Drupal Root Directory.
And Vice-Versa when the Download Manager set to "Private Download", you got an Denied Access.
In few words :
- Set a Temporary directory inside the Drupal Root in
admin/settings/file-systemif you want to use the Public Download - Let the Drupal's Temporary directory by default (in the php.ini) if you want to use the Private Download
Why do you leave the user to set himself the Public/Private download which could be confusing? and instead use the Drupal setting ?
In this case, insert somewhere:
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
// Public method
} else {
// Private Method
}
Comments
Comment #1
Nicolas Georget commentedAnother thing that i figured out in my test: with the option "Allow subdirectory listings.", you can download a Zip archive with some files inside (Files are in the root dir_listing).
Without this option, you got an Denied Access:
Comment #2
Yoran commentedThe separation of public/private settings from drupal comes from the fact that most of the time a site is configured to public and also need to have "private access to specific files" through filebrowser.
The second reason why a "download" manager, is that some user of this module have petty customized version of the way of handling files download. As an example, one user make a random simlink to real file in order to both security and apache speed.
As a conclusion, we can imagine to have a "Drupal settings download manager" as third option, letting people who need it to override such settings.
Comment #3
Yoran commentedI fixed the first issue (in dev) but I don't really understand the second one. Can you give me the steps to reproduce this ?
Comment #4
Nicolas Georget commentedNever mind because i'm not able to reproduce 2nd comment :(
Anyway, i get an empty ZIP archive when i download as ZIP a folder now and the following errors:
You get the same ?
I understand why Drupal must handle 2 ways of handling files. But my point was why do you handle it twice. Maybe i say something stupid but let drupal do it
variable_get('file_downloads', ...Or you have an another reason in the filebrowser mechanisms that i don't get it (for sure):
Can you explain a bit what is the difference for your module, technically speaking ?
Comment #5
Yoran commentedNo success for me to make zip archive fail. I tried public/private, with or without checking a file, it works fine here. Is your test made in a subfolder ? Are you using linux ?
I didn't make myself clear. My point wasn't about the interest of having 2 methods (private and public) but in the fact that for most installations, you don't want to have the same settings in drupal AND in filebrowser. For example, I have many site that are running under drupal "public" method, but also give access with filebrowser to folders that are not in drupal root. Other example is people that have a mix of filebrowser folders with both public and private methods depending of security issues, root folder position, etc.
My second point was that drupal know only 2 methods (private/public). Filebrowser is designed to handle very customized download methods (using specific hooks) in order to handle very specific situations (for example some people are making random symlinks to use apache for serving "private" files, some other people are using this to check specific file rights against some specific webservices, etc.).
So Drupal public/private settings can be a default for filebrowser (I'll do that soon) but can't be used for all filebrowser nodes.
Comment #6
Nicolas Georget commentedYes for the both questions.
Ok. understood. Because for me, the only difference was the method used into the function
filebrowser_filebrowser_download_manager_process():header("Location: " . url(trim($target, '/'), array('absolute' => TRUE)));I did not consider the other cases like symlinks, security issues, etc...
Comment #7
Yoran commentedOk so your problem is "zip selected files from a subfolder leads to an empty zip file", right ? Did you try from root folder ?
Comment #8
Nicolas Georget commentedOk. let's say a tree like this:
When i check the checkbox in front of the folder
~test/iconsand choose the action "Download selected items as an ZIP archive (only files)", i get an empty archive....Aïe, aïe, aïe... Quel con(*) !!!
By copying and pasting the action text "Download selected items as an ZIP archive (only files)" I just noticed the last and the most important part: (only files) !!!
This action only works for files right ?? not for a folder and its content !!
(*) in french /kɔn/, means i'm an idiot, a dummy....
Comment #9
Yoran commentedYep, only files in zip :))) We can try to make better for next release if you want => feature request ?