Thanks for this module, first of all. Filetree is a great module and I couldn't find anything else that did what it does so simply and cleanly.
I am running into a major problem right now, though. I am using private filesystem and I am using simple access to control access to the filetree node. I can browse the tree and see the files, but none of them will open when clicked. I get a standard Drupal Page Not Found Error. All of the files being retrieved are .TIF extension.
I have tested changing the filesystem rights to 777 so I am pretty sure it's not an access rights issue. I moved a chunk of the file structure to the public files area, switched Drupal to public filesystem and I was able to download the files just fine. As soon as I switch it back to the private file system I get the Page Not Found Error. How can I help troubleshoot this?
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 0001-Drupal-Filetree-Add-private-file-downloader.patch | 4.16 KB | RSpliet |
| #12 | 0001-Drupal-Filetree-Add-private-file-downloader.patch | 4.16 KB | RSpliet |
| #11 | 1185198_11_Filetree_private_file_downloads.patch | 2.55 KB | johnv |
Comments
Comment #1
joelstein commentedIt seems to work for me. But it was a little trick. Supposing your files folder is at sites/default/files, and your private files folder is at sites/default/files/private, and you have a folder in there called images, and your default download method is set to "private" at "admin/config/media/file-system", you could make it work like this:
[filetree dir="images"]
All those files will be written with their private files URL.
With the same assumptions as above, except this time your default download method is set to "public", you'd have to use this value:
[filetree dir="private/images"]
However, it should be pointed out that in this second example, your files will be written with their public URL, which of course will return 403 Forbidden when clicking on them.
Hope this helps!
Comment #2
movinr8along commentedThanks for the quick and clear response. I really appreciate it. Your description matches well what I have put in place.
Just to clarify, in my setup, as in yours, the private files directory is a subdirectory of the public files directory, with the appropriate .htaccess "deny from all" setting at its root and I am unable to call up any files from the directory by typing their URL into the browser. Testing File Tree's behavior with private and public settings in "admin/config/media/file-system", I am able to browse the folder structure of the private files area with File Tree, but File Tree will not open/download any files from within the private files area, regardless of the setting for private or public at "admin/config/media/file-system". Am I correct then in understanding this is by design and that file tree will not allow me to download any file located in the private file system area, although I am able to browse them?
Comment #3
joelstein commentedThat's how it seems. There may be a way to determine whether or not a file should be displayed with a public or private URL... but I don't know how to do that. I welcome any patches.
Comment #4
movinr8along commentedI took a look into it. Just to preface, I am not a php guru at all.
I did some reading and it appears that in order to retrieve any file through the private file system it must exist in the database and then it is called using hook_file_download so that permissions can be checked and honored. A sample of how this can be done was provided in this post:
http://drupal.org/documentation/modules/file#comment-4104464
The whole thread discusses some of the security problems with private downloads and helped me understand it much better.
Needing the files to be referenced in the database is probably the first hurdle since filetree doesn't appear to store the files in the Drupal database as proper file entries, but just caches a collection of direct access links. The lack of file field entry in the database probably explains why Drupal gets a /system/files/filename link and returns a 404 since it doesn't know there is a file there. Does this sound at all right to you?
Comment #5
Anonymous (not verified) commentedSubscribing.
Any news on this subject?
I'm facing the same problem:
I want to display a file tree of the files in private subdirectories but I get a 403 error because the URL is pointing to the private folder instead of using Drupal's private URL resolution like in the nodes with attached private files.
Comment #6
joelstein commentedMarking #1258436: [PATCH] Add private file downloader as duplicate, and opening this discussion back up, since it seems that we don't yet have a good solution for private files.
There are obviously security issues here. Please provide use cases (scenarios) so we can find a generic way to solve this that won't cause security problems.
Comment #7
RSpliet commentedWell, in terms of use cases there are (at least) two ways of looking at this problem:
1. The administrator publishes a file tree. Different files in that tree belong to different users. Therefore permissions should be arranged on file system level. Eg: keeping a list of Drupal roles for each folder.
2. The administrator publishes a file tree. All files inside that tree are "published", and therefore should be accessible by anyone with rights to see the node where the file tree is in.
Option one (folder level) is fairly easy to implement, and has many ways of doing so. In fact, this could be implemented into a separate "private file downloader" module, not really related to Filetree. The easiest way is to introduce a hidden file that defines the roles that have access to the files and folders inside. That way no traces (database mess) are left when you remove a folder. Downside is, as stated before, adding another layer of role management. Also, rendering the tree must adhere to these permissions as well to be practical.
Option two (filetree/node level) would therefore have my preference with the existence of nodeaccess modules, but does not appear to be so simple to implement. The clear advantage is that it comes closer to an "it just works" environment. The admin doesn't have to worry about a new security mechanism but instead controls the node rights. The downside is that it involves quite a lot of work
- Downloads should be linked to the node that serves the file tree
- Upon downloading, it should be checked that the user has access to the node
- Upon downloading, it should be checked that the node is actually presenting this file.
Especially point 3 is difficult, as we would have to check the text input types to see if filetree is enabled, check all fields for this node to be of one of these types, and then scan the availability of one or more file trees in this node that then also needs to contain the path required.
Perhaps it's like swearing in church right now, but it might be easier to have a (complex) field type "filetree". Not only would this help in this problem by greatly simplifying the work of finding "what folders is this node serving", but might also give new ways of dealing with the caching problem of #1139866: auto refresh filetree listing or make real-time?. However I can only assume that the choice for a filter rather than a field type has been researched when designing this module, rendering this option undesired.
The (ruled out) patch in #1258436: [PATCH] Add private file downloader adds a simple private file downloader which is pretty much a copy from the IMCE module. It has great security issues, but might be useful for some controlled environments. However, I agree that a definite option should be found to serve private files. I personally however do not feel the solution should be sought in creating database items for the files in the tree. One of the major advantages of this filetree module is that it can handle something as dynamic as a (network) file system folder. Having to maintain a database of files (in a probably hacked up way) will make a filetree system probably lose that advantage as it will not be triggered whenever a change in the folder occurs.
Comment #8
Anonymous (not verified) commentedMy use case is the following (at least this is what I'm trying to achieve using File Tree):
I have a content type with a field for the user to upload some file. That file should be placed in the private directory (actually a subdirectory, using the FileField Paths module to determine the full path), preventing it from being served directly by the server (and thus, the file cannot be downloaded using the complete URL). So far, I can achieve this when viewing the published node, i.e., the file is only accessible to registered users.
The File Tree is used when I want to display a complete listing of the files associated with that content type. Since they're in the private directory, File Tree tries to use the URL for the private directory and therefore I get an 403 error.
The way I see it, one possible solution for this would be checking if the file is inside the private directory and force the same "download method" that is being used when the file is downloaded from the published node page. Of course, the private directory path may be customized and I don't know if the FileTree Module has access to that value, but if it doesn't, a settings page for the module in the Administation page requiring the admin to enter the base path of the private directory should do the trick.
I hope this is helpful to find a way to solve this issue.
Comment #9
trigdog commentedsubscribe
Comment #10
johnvdouble post.
Comment #11
johnvPlease find attached the patch from RSpliet from #1258436: [PATCH] Add private file downloader. Minor non-functional changes, and includes #1313532: Admin settings page.
Comment #12
RSpliet commentedAttached patch is a rework of the original patch posted in #1258436. Improvements include better coding style (by using hook_help, by adding the variables in the install routine) and a "force file download" option to make the browser download instead of open in the existing window.
Comment #13
RSpliet commentedThis patch invalidates the patch posted earlier. Fixes a nasty warning in hook_help() and now applies cleanly to upstream git without whitespace errors.
Comment #14
narenpg commentedis this patch already checked in.? i tested this patch against filetree-7.x-2.1. and it fails.
Comment #15
jochen wendebaum commented.