In my case, using the generic files display, pdf files are always downloaded. No choice is given to the user.
The site file system is set for private.
This problem occurs in all browsers and is independent of the browser pdf plugin.
If I use Drupal core File Attach, files are readable in the browser in all cases.
It is independent of the subfolder in which the files are stored, ie, same folder, File Attached pdfs are readable and filefield pdfs are not.
Once downloaded, the filefield pdfs can be opened within a browser. A byte-wise comparison of an uploaded and downloaded file shows them to be identical.
I have used the filefield generic files theme plus several variants in my template.php including the equivalent of the upload module display theme. No difference.
The file mime type is correctly determined by Drupal (with or without using the mimedetect module). The mime type is correctly stored in the database and can be downloaded onto the node page as file information.
I can only think that in the function filefield_file_download(), or somewhere else, the mime type is signalled to the browser (but not stored) as application/octet-stream. However I can't find where or how this is happening.
Can anyone help please?

Comments

quicksketch’s picture

You can specify which file types should be shown in the browser (vs. being downloaded) when using FileField and Private files by setting a variable your settings.php file such as this:

$conf['filefield_inline_types'] = array('application/*', 'image/*', 'text/*', 'flash$', 'audio/midi?');

I'm not really sure what the PDF file is being stored as in the database. You might want to check the "files" database table and adjust the variable to match whatever mime type PDFs use.

See #485336: Make Content-Disposition configurable for private downloads for background.

GrahamShepherd’s picture

Excellent, thank you. That worked. The pdf file mime type is stored as application/pdf.
I suggest adding something to README.txt for others.
Ideally this would be configurable in the content type - default inline but can select force download by file type.
Since filefield is now in core, should this be submitted as a feature request for Drupal 8?

quicksketch’s picture

quicksketch’s picture

Status: Active » Closed (fixed)