搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Cannot make JSON files downloaded automatically

  • 10 回覆
  • 1 有這個問題
  • 641 次檢視
  • 最近回覆由 pzixel

more options

I'm downloading lots of JSON files on day-to-day basis and I'm tired of selection download action because FF doesn't have a "remember" checkbox for it (see image below).

You can reproduce it: go to any site that allows you to download jsons, e.g. https://petstore.swagger.io/#/pet/findPetsByStatus

If you execute any request there will be a `Download` button If you click it you will see a popup similar to attached one: no "remember" checkbox.

How do I make it remember my choice?

My FF version is 77.0.1 (64-bit), Windows 10 2004.

I'm downloading lots of JSON files on day-to-day basis and I'm tired of selection download action because FF doesn't have a "remember" checkbox for it (see image below). You can reproduce it: go to any site that allows you to download jsons, e.g. https://petstore.swagger.io/#/pet/findPetsByStatus If you execute any request there will be a `Download` button If you click it you will see a popup similar to attached one: no "remember" checkbox. How do I make it remember my choice? My FF version is 77.0.1 (64-bit), Windows 10 2004.
附加的畫面擷圖

被選擇的解決方法

Hi pzixel, the extension is designed to watch network responses, detect the file's extension, and override aberrant headers before the information reaches Firefox so that the download works correctly. It has a limited mission in that respect.

Your first screenshot references a blob: which definitely sounds like a locally constructed object. Would it be possible to inject a script into the page to modify how that save works? Perhaps, but I don't think I'm personally up to the task.

Your second screenshot is a network request, but perhaps it is a background request? The extension has a filter which looks for main frames and subframes, so that may exclude XHR requests. Also, the request URL doesn't have a file extension, so it needs a very different kind of approach.

從原來的回覆中察看解決方案 👍 1

所有回覆 (10)

more options

More than likely the file doesn't have a MIME type attached to it.

Please see this support article for an explanation:
https://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file

If so, that needs to be fixed on the server where those JSON files are downloaded from.

more options

I see, but why I can't set preferences for file extension? Okay, there is probably no MIME but there is an extension. I'd like to be able to setup file opening preferences based on extensions, is it possible? Becuase there are plenty of sources where files are not marked with MIME, and it would be sad if I wouldn't be able to configure their behaviour.

由 pzixel 於 修改

more options

See if this extension helps you:
https://addons.mozilla.org/en-US/firefox/addon/content-type-fixer/

Sorry, that new extension slipped my mind before. Been up too many hours already ...

That extension developer has been doing support here for many years now and stumbling a posting he made in a different thread a few minutes ago, "toggled" my memory a bit.

more options

Cool, I think that's what I need. Unfortunately, it doesn't work to me. Maybe I need to report a missing use case there. Anyway, thanks for the link.

more options

"Support site" for that extension / add-on:
https://github.com/jscher2000/Content-Type-Fixer-extension/issues

Per the download page, "More information" section in the left column.

more options

Yeah, it looks like I won't be able to do it. I'l create an issue to make it possible. Thanks for help.

more options

Hi pzixel, if the download does not appear in the log, even after refreshing, it may indicate that the file was constructed by a script in the page instead of being requested over the network from the server. Currently, the extension only modifies responses coming in over the network. (I actually have no idea whether it is possible for an add-on to "see" downloads triggered by scripted save actions.)

more options

Right, it's most definitely is constructed by script (there is no network interaction when button is pressed).

Instead of detecting if something is transferred I'd propose to just allow to manually add or remove entries and probably FF will use this mapping when this file gets to the download window. I'm not sure it will work because I see requests but I don't see anything in `.ext` column. Maybe *actual* file transfer doesn't show up here.

So, being said, maybe allowing manually adding ext -> action entries would help.

If extension only adds MIME to already known files (and it cannot affect how FF interacts with files overall) then it won't be able to do its job properly in this case.

由 pzixel 於 修改

more options

選擇的解決方法

Hi pzixel, the extension is designed to watch network responses, detect the file's extension, and override aberrant headers before the information reaches Firefox so that the download works correctly. It has a limited mission in that respect.

Your first screenshot references a blob: which definitely sounds like a locally constructed object. Would it be possible to inject a script into the page to modify how that save works? Perhaps, but I don't think I'm personally up to the task.

Your second screenshot is a network request, but perhaps it is a background request? The extension has a filter which looks for main frames and subframes, so that may exclude XHR requests. Also, the request URL doesn't have a file extension, so it needs a very different kind of approach.

more options

Yeah, that's what I was affraid of.

Thanks for reply anyway, now I see more clearly what can I expect. I'm glad you replied.