How to remember last download location when calling chrome.downloads.download? (Extension Developer)

10,168

Solution 1

It's concerning that Chrome actually doesn't provide the ability for an extension to get the last download path. Some say, it's due to security concern and others say, there is no significant need to have the API available to users.

You also cannot store the download path in your extension because Chrome doesn't let you get the selected download folder. I hope Google provides us with the either of these features later.

Solution 2

This is not a supported feature, according to this Chromium discussion.

Summary:

  1. If you specify a filename, it's never possible to save outside of ~/Downloads (this is a bummer, for me)
  2. You should be able to manually implement something (in a subfolder only) using the id returned from Chrome.downloads.download

A few quotes I like (edited for brevity and politeness):

Would like a download option to choose recent download folder. Would be good to remember last download location per website, like you other settings.

Seems reasonable.

Chrome does remember the last chosen directory if no filename is specified to downloads.download with Save As... Given how Save As works without specifying a filename, my intuition would be it would work the same with a filename... but it doesn't.

That one is interesting. So it kind of supports it already. There's no security concern with saving outside of Downloads.

Solution 3

I have just been able to restore the "remember last download location" functionality, which used to work on my previous machine, in a new install by disabling extensions and Chrome apps provided by Google. This is what I have turned off:

  • Extension: Google Docs Offline
  • Chrome Apps: Docs, Sheets, Slides

I haven't tried to narrow down which of these have been the culprit, or if any other extensions (I have a bunch) have played a role. So YMMV. Good luck :)

Share:
10,168

Related videos on Youtube

Aero Wang
Author by

Aero Wang

Panda in Shanghai. :)

Updated on July 12, 2022

Comments

  • Aero Wang
    Aero Wang almost 2 years

    The default behavior for chrome.downloads.download is to download to the default download folder. It doesn't remember it if you change the folder. Can we save the download-to location for the next call-out?

    References: https://developer.chrome.com/extensions/downloads

  • SimplGy
    SimplGy about 5 years
    Do you have any references you can share? (eg: a feature request where it's acknowledged that this doesn't exist, or a bug report)
  • mythofechelon
    mythofechelon over 3 years
    I can confirm that using saveAs: true but not filename: does allow the download folder to be remembered.