Hello,

I try to use the File Force module on Drupal 7.0. The filepath seems to be correct (http://.../file.pdf?download=1 as known from D6) but if I click on the file link it always opens in the browser window.
Can it be that it is again only available on private file system methods? Currently I use the public file system method.
Unfortunately I can't switch to private for testing purposes because it's a live site.

Help is much appreciated.

Thank you
Stefan

CommentFileSizeAuthor
#5 file_force-public-files-1047394-5.patch1.67 KBlee20

Comments

arski’s picture

Title: File Force opens files in browser window » File Force on top of public download method

Hey,

Yes, I'm afraid FF only works with the private download method enabled at the moment (see readme).

I wasn't really sure if I wanted to make it work with the public download method, because by definition, it's impossible. The public download methods means that files are downloaded directly from the server, i.e. without Drupal doing anything at all.. and making FF work with that means creating a formatter with a custom-defined URL path that goes around the download method setting completely, which doesn't seem to make too much sense to me.

Anyway, would be interesting to hear some people's thought on this.

Cheers

e5sego’s picture

Workaround

It is possible to use FF with public file method if you setup your webserver to add special mime type header if download=1 get-parameter is present. For apache this can be done by adding following lines to .htaccess file in root of public download folder (or main install folder):

RewriteEngine On
RewriteCond %{QUERY_STRING} download=1
RewriteRule .* - [T=application/octet-stream]

Now you can use FF module or simply add ?download=1 to file url's in your theming code.

justinlevi’s picture

Thanks for the htaccess rule. That was exactly what I was looking for.

arski’s picture

Status: Active » Closed (won't fix)

File Force Download module itself will not be providing support for the public download method in D7 due to the reasons outlined above, namely that a public method does not go through the Drupal stack and hence shouldn't be messed with.

A .htaccess solution is not as lean maybe, but you're always more than welcome to go for it.

lee20’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Category: support » feature
Status: Closed (won't fix) » Needs review
StatusFileSize
new1.67 KB

a public method does not go through the Drupal stack and hence shouldn't be messed with

Not sure why you wouldn't just reroute public files through the system.

Here is a patch that makes FF work with public files.

This adds a menu callback so that public files can be sent through the routing system. The menu path is configurable but there is no admin for this. If there is interest, I can add this.

arski’s picture

Well, this is exactly what the D6 version of the module does. If I remember correctly, I have tested the D6 approach in D7 and ran into some issues there, mainly with the files simply not being found as they were placed in different storage depending on what download method the site uses..

Have you actually tested your patch and can confirm that it works for you?

lee20’s picture

Yes I have tested it and it works great. It merely detects and overrides the URLs for public files and should have no impact on private files.

arski’s picture

Alright, I'll take a look at porting the D6 code back in for consistency, as I said, it is almost identical to your patch.

lee20’s picture

Awesome. There is one thing I just noticed. My patch didn't account for the the call to file_create_url() in the file_force_formatter.inc file. I would provide another patch but since your going to port it just thought I'd point this out.

arski’s picture

Yeah, I'll go through everything again anyway, thanks.

arski’s picture

Status: Needs review » Fixed

And committed, lovely. I was originally reluctant about doing this approach, but what the hell. Enjoy :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.