Search code examples
downloadfirefox-addonfirefox-addon-sdkmozillabrowser-addons

Downloading a file from my mozilla addon sent by the server


I am developing a amozilla addon , and I have to download a file that is stored in the server. I would retrieve the file from the server using xmlHttpRequest. My question is how I download the response file in my browser from my mozilla addon


Solution

  • You can use xmlHttpRequest with requestType of arrayBuffer, then use OS.File to write that to file: https://stackoverflow.com/a/25492679/1828637

    This way does not show in the download manager, if you want it to show in the manager then you should use Downloads.jsm module: https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Downloads.jsm