this post was submitted on 20 Dec 2023
296 points (98.1% liked)

Firefox

16974 readers
137 users here now

A place to discuss the news and latest developments on the open-source browser Firefox

founded 4 years ago
MODERATORS
296
submitted 6 months ago* (last edited 6 months ago) by PropaGandalf to c/[email protected]
 

Hey guys

Today I got so annyed by firefox's default behaviour of downloading each and every PDF file to my disk that I went searching for a solution until I had the problem fixed. And it seems like I have finally found it. I have linked the solution but here is the explanation in short:

Firefox determines what kind of file type it is based on the content-type header it receives from the server. Another header is the content-disposition header with which the server specifies how the file should be handled. The two most important options here are attachment and inline.

  • inline is the default if not otherwise specified, and means the browser will handle the file according to the behavior set in the browser settings.
  • attachment means to always download the file

It is therefore possible that some pdf files are downloaded by force and others are handled according to the behavior specified in the settings. To force the latter in any case, you can proceed as follows:

  1. go to about:config
  2. change browser.download.open_pdf_attachments_inline to true

Thank you jscher2000 for the solution!


cross-posted from: https://lemmy.world/post/9785046

all 42 comments
sorted by: hot top controversial new old
[–] [email protected] 50 points 6 months ago (1 children)

THANK YOU. This behavior has been bothering me since it was introduced but I thought there was no solution

[–] assa123 6 points 6 months ago (1 children)

After watching other comments I wonder why some people don't get that this was a bug or at the very least, undocumented behavior outside of the Settings GUI. I had to deal many times with file (4).pdf on my Downloads dir. A BIG thank you, OP.

[–] [email protected] 5 points 6 months ago (1 children)

Yeah, it's the classic "works for me" problem

[–] PropaGandalf 1 points 6 months ago (1 children)

I know now why some people may not have this problem. It really depends on the server and if it marks the content-disposition header as attachment forcing the files to be downloaded. I edited my post now so that this is clear.

[–] [email protected] 1 points 6 months ago* (last edited 6 months ago)

That makes sense! Thank you for taking the time to dig into it

[–] [email protected] 21 points 6 months ago* (last edited 6 months ago) (2 children)

it isn't in right in firefox's settings -> general -> under 'files and applications' ??

'open in firefox' (what you want), vs 'always ask', 'always save' (download) or 'open in default application' (such as adobe reader). actions are configurable for many file types.

[–] [email protected] 32 points 6 months ago

I believe even if you choose “Open in Firefox”, it will still download the PDF to the default download directory before opening it inside a Firefox tab. The behavior that OP describes above seems to prevent that downloading (and having the file around in your default download directory).

[–] Humanius 14 points 6 months ago* (last edited 6 months ago) (1 children)

I don't know whether they fixed it since, but last I checked that option was broken.
No matter what you select, half the time it still downloads the PDF to your drive.

[–] PropaGandalf 4 points 6 months ago (1 children)

It even says in the description that these settings determine how firefox will handle them after downloading them.

[–] [email protected] 1 points 6 months ago (1 children)

i have 'open in firefox' enabled on this pc for pdf. i never get a dl prompt. goes right to the internal pdf viewer every time.

[–] Humanius 9 points 6 months ago* (last edited 6 months ago) (1 children)

The problem is not that it gives a download prompt, but rather that it tosses the PDF file into your downloads folder unrequested.
It opens the PDF in the internal PDF viewer as well, but that is not the thing people are having issues with.

[–] [email protected] -1 points 6 months ago* (last edited 6 months ago) (1 children)

NONE of the files i tested it on triggered the download prompt, populated the download status of the browser, or appeared in my default downloads location during their 'viewing' or after.

[–] Humanius 6 points 6 months ago

Great that it seems to work for you, but I've been experiencing this bug for months now if not longer.
I made the changes OP suggested, and now it seems to work correctly.

[–] [email protected] 11 points 6 months ago* (last edited 6 months ago)

Good on you for sharing! This behavior has been so infuriating to me

[–] [email protected] 11 points 6 months ago (2 children)

It does not fix the bug, i want to save in tmp & use external application like it did until last year

I don't want to have the same behaviour of chromium browsers, otherwise i would use chromium browsers.

Luckily microsoft updated ms edge on linux to save on tmp the files that you want to open, but you don't want to save. It's the only browser left that does that with a simple check in settings and doesn't require big workarounds. Used to be only firefox to do this... pity

[–] [email protected] 6 points 6 months ago* (last edited 6 months ago)

That sounds like browser.download.start_downloads_in_tmp_dir combined with “open with…”. That setting should download to tmp whenever you open it directly in an application. The other setting (browser.download.open_pdf_attachments_inline) should only be enabled if you want to open PDFs in the browser without downloading them.

[–] PropaGandalf 2 points 6 months ago (1 children)

Can't you change that in the folder settings? Changing it to a temp folder?

[–] [email protected] 2 points 6 months ago

But then when I want to save and keep the file, i have to browse to the real downloads directory

[–] [email protected] 7 points 6 months ago* (last edited 6 months ago)

Iirc, I had to set that firefox doesn't open everything in the browser but downloads the pdfs to disk. It was in the settings.

I really didn't get the idea why I had to save pdfs manually. To me, it feels weird to not save pdfs automatically but I understand you if you rarely safe a pdf.

[–] [email protected] 7 points 6 months ago* (last edited 6 months ago) (1 children)

Set the default download folder to /tmp. In the rare case you actually will need a file you download later, copy it to a better directory.

[–] PropaGandalf 11 points 6 months ago* (last edited 6 months ago)

I still prefer storing the pdf in the browser cache and downloading it manually if I want so than to download it directly to /tmp or anywhere else.

[–] [email protected] 6 points 6 months ago

Nice! Thanks for the tip!

[–] [email protected] 6 points 6 months ago

Wish that worked on the android version as well :(

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago) (1 children)

You can specify where you want the temp download folder to be fyi. It's in the normal settings. Just make a folder in like C:/firefox temp files and have it dump all that shit in there.

[–] PropaGandalf 1 points 6 months ago

I know but I don't want it to be shown in the downloads panel or get any notification I just want it to store it temporarily in the browser cache and ooen it in a new tab. Like a regular website. And if I really want to download something it should go directly to my regular download folder.

[–] eager_eagle 3 points 6 months ago* (last edited 6 months ago) (2 children)

Even with browser.download.open_pdf_attachments_inline set to false (default), Firefox already opens PDFs instead of downloading them, thanks to this setting:

For what use cases is that needed?

[–] [email protected] 4 points 6 months ago

That option did not work for me

[–] PropaGandalf 3 points 6 months ago* (last edited 6 months ago) (1 children)

For me it still downloads and then opens it in firefox. In the description it clearly says: Choose how Firefox handles the files you download from the web (...). And I don't want it to download the file to my disk in the first place just store it in chache like a regular website.

[–] eager_eagle 2 points 6 months ago* (last edited 6 months ago) (1 children)

it doesn't download them for me, unless I explicitly save the PDF that opens

like this example.

(akhtually it'll always download in order to open it, I just mean it doesn't create a PDF in the downloads directory)

[–] PropaGandalf 1 points 6 months ago* (last edited 6 months ago) (1 children)

Which firefox version are you on? I'm on 122.0b1 (flatpak beta) and changing these settings just defines what happens after I download the file. Also my download folder is set to ~/Downloads

[–] eager_eagle 2 points 6 months ago* (last edited 6 months ago) (1 children)

121.0 stable, .deb from Firefox's ppa

interesting

[–] PropaGandalf 1 points 6 months ago (1 children)

Wait do you download the files to you /tmp dir? Or do you store the files in the browser cache?

[–] eager_eagle 3 points 6 months ago

my downloads dir is ~/downloads/ but Firefox doesn't create a file there, so it must use a temp location for the PDF that opens.