I'm new to Firefox addon development, and it's going well so far, but I'm stuck on how to, essentially, download a file from the Web, given a URI, and save it to disk. Mozilla's MDN documentation has information on how to upload files, but the downloading files section is empty and yet to be written. Sadly, I haven't found any documentation which describes how to do this.
Does anyone know of relevant documentation on how to do this?
The old Facebook Photo Album Downloader addon uses this function call in its overlay JavaScript:
saveURL(images[i].replace(/\/s/g, "/n"), null, null, false, true, null);
Obviously, the first argument is the URI to request. The saveURL
function isn't defined anywhere, so I assume it's an extension API function. I have tried it in my new addon, and it does work. I would, however, like to know what the other arguments mean.
Configure Internet security software Check the settings in your security software to see if there is an setting that may be blocking downloads. To diagnose whether Internet security software is causing problems, you can try temporarily disabling it, seeing if downloads work, and then re-enabling the software.
Extension MetadataIt's an official Firefox extension by Free Download Manager developers. The sole purpose of this add-on is integration with FDM. FDM is a fast and reliable download manager and accelerator that improves your experience with downloads and helps you organize them in an easy manner.
Download the file to your local computer. , click Add-ons and Themes and select Extensions. To add the downloaded add-on to the list of available add-ons, drag and drop the file into the Add-ons window. The add-on is added to the list.
The standard way to do this is with nsIWebBrowserPersist:
var persist =
Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].
createInstance(Ci.nsIWebBrowserPersist);
persist.saveURI(serverURI, null, null, null, "", targetFile);
See https://developer.mozilla.org/en/Code_snippets/Downloading_Files for more info.
There actually is some MDN documentation on this: https://developer.mozilla.org/en/Code_snippets/Downloading_Files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With