Closed (fixed)
Project:
File Force Download
Version:
6.x-1.1-beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
20 Feb 2009 at 11:20 UTC
Updated:
14 Aug 2010 at 14:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
Garrett Albright commentedThough I haven't thoroughly tested it, I would think that File Force would work with private downloads enabled. Could you be more specific about what's not working?
Comment #2
Mark Theunissen commentedSure, when you call the file_download() function, File Force passes in the full path 'system/files/image.jpg'.
However, when using private downloads directly, the menu item ['system/files'] maps directly to the file_download() function, and thus it only passes in the file name, i.e. it gets 'image.jpg'.
Put a breakpoint in file_download and see the difference in the arguments.
Thanks!
:)
Comment #3
Mark Theunissen commentedHi Garrett, have you had a chance to look at this?
Comment #4
Garrett Albright commentedSorry, no. I've been cramming on other projects lately… It may be a while before I'm able to.
Comment #5
polI'm really interested in private download too !
Comment #6
polHi Guys,
I really need to get this working for a customer, so I hack the code myself and succeded to do it !
How to get it working:
1) Edit the file "includes/file.inc"
2) Replace the function file_download() by this one:
3) Enjoy
4) I've included the patch. This is the first one, I'm sure it's not the best, but at least, I'm trying ;)
Comment #7
polUpdate ! Small bug fix
Replace the function includes/file.php::file_download() (near line 840) by this one:
Comment #8
Garrett Albright commentedAck! Don't hack core!
Comment #9
polYes we don't have to hack in the core.
But here, without those 3 lines, all the modules that implement file_download() will never be used !
These are the 3 lines of code to add:
It's impossible to do it in an other way!
So... what to do ?
Comment #10
polI committed the patch to core.
It's related to file_force but it's a small bug in file_download()
Link: #432332: Private path and file_download
Comment #11
marcoka commentedso it is fixed? because the issue is still open.
Comment #12
arski commentedHey,
It appears that that patch has never been accepted :( let's see what I can do to help with this.
Cheers
Comment #13
arski commentedHey there,
All right, I looked into what's going on here and have a pretty good idea of what needs to be done. But first, here's a small overview of how the download system works in Drupal:
The "download method" setting has an effect on only one place - the file_create_url function in includes/file.inc. If you set this to "public", the urls will be generated as real file paths, but if you set this to "private", 'system/files/' will be prepended to the file name. What this does is make sure that the file isn't fetched straight away, but that you are redirected to the 'system/files/' page, which is a usual menu callback defined in system.module. Now all this callback does is send the file received as the argument to "file_download", which subsequently calls the hook_file_download hooks all over the place.
So long story short: the way file force was designed until now, it was basically just emulating the "private" download method, just instead of the 'system/files/' menu item, it was using 'download/'. "Public" download method practically doesn't exist anyway anymore if you prepend 'download/' to your file path.
So what this means is that for this module to move forward, and allow more configurable download settings for different fields etc. we need to respect the underlying system (unfortunately, there is no hook to rewrite the system/files url) and build on top of that. So from the next release:
1. File Force will only work if the "private" download method is selected.
2. There will be additional view options for Views and Templates to automatically generate file_force URLs for your selected field.
3. To set file_force manually for a selected file of your choice, you will need to append "download=1" query to your link.
Just wanted to share what I learned today, updated module coming up soon :)
Cheers,
Martin
Comment #14
arski commentedAll fixed up and ready to use in the -dev, which should be online within 12 hours.
Apologies for yet another file path change, but that was really needed to make this module applicable all across the board.
Cheers