I have a View which offers (private) File Entity PDF files for download via the "Download link" formatter.

In Android (at least the stock browser and Chrome on Android 4.2.2), the file downloads to the Downloads folder, but the browser cannot open the file - you get the message Cannot open file. You have to exit the browser and browse to the Downloads folder, which is a pain.

It turns out that when using the Download Link, File Entity delivers the files with the HTTP header Content-Type: force-download.

After Googling I found this:
http://www.digiblog.de/2011/04/android-and-the-download-file-headers/

If you use any of the lines below your download will probably NOT WORK on Android 2.1.

Content-Type: application/force-download
Content-Disposition: attachment; filename=MyFileName.ZIP
Content-Disposition: attachment; filename="MyFileName.zip"

And the solution
To make it work in Android’s stock browser and in Dolphin browser you have to use:

Content-Type: application/octet-stream
Content-Disposition: attachment; filename="MyFileName.ZIP"

So it looks like 'force-download' is a hack too far, and 'application/octet-stream' should be preferred.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pjcdawkins’s picture

Status: Active » Needs review
FileSize
615 bytes
aaron’s picture

I am not able to test on an Android. However, in testing on my PC I experience no issues with this patch.

aaron’s picture

Issue summary: View changes

More detail

Dave Reid’s picture

I read quite a few more links today about file download headers and the most consensus I saw was to actually use the file's real mime type in the Content-Type header. Can you test this patch out and see if it still work for you mobile devices?

Dave Reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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