marklieberman / downloadstar

Download all items in a webpage that match a pattern
GNU General Public License v3.0
90 stars 16 forks source link

Add absolute download path #42

Open msdobrescu opened 6 years ago

msdobrescu commented 6 years ago

It is difficult to set a relative download path. Please add absolute download path support, if WE allows it. Thank you.

marklieberman commented 6 years ago

It is not possible to save files outside of the Downloads folder configured by Firefox. This is a deliberate decision by the Firefox developers.

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads/download

filename A string representing a file path relative to the default downloads directory — this provides the location where you want the file to be saved, and what filename you want to use. Absolute paths, empty paths, and paths containing back-references (../) will cause an error. If omitted, this value will default to the filename already given to the download file, and a location immediately inside the downloads directory.

marklieberman commented 6 years ago

Related BugZilla bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=1342563

It may be possible to prompt once and then re-use the absolute folder if the bug gets patched. At priority P3 it could be months or years, unless someone decides to contribute a patch in the near future.

msdobrescu commented 6 years ago

Interesting, why is it possible to download in any place with Firefox? I can save anywhere I please with Firefox's download manager.

marklieberman commented 6 years ago

@msdobrescu Simply because the native Firefox manager and downloads are using internal Firefox code. They are not written as web extensions and therefore have no restrictions in what they can do.

buttercookie42 commented 5 years ago

I wonder whether something would be possible through native messaging, e.g. leveraging the native ext extension. That would allow packaging an additional script with the extension, which native-ext would then execute as a normal node.js script, so that additional script would have full user-level access to the file system.

Then, in the main extension you could detect if native-ext support is available, and if yes, unlock the ability to choose an arbitrary target path. Then,

  1. Download each file into a temporary directory underneath the default downloads directory permitted by Firefox.
  2. As each download in turn finishes, ask the native extension part to move that file to its intended final location.
  3. Once all downloads have finished, ask the native extension to delete that temporary directory again.