Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox web extension - read local file (last downloaded file)

Tags:

People also ask

How do I open a downloaded file in Firefox?

Right-clickHold down the control key while you click the downloaded item in the Downloads panel. (You can also do this from the Library window Downloads history.) Select Always Open Similar Files from the context menu.

Where are Firefox Downloads stored?

Click on the Downloads button to open the Downloads panel. The Downloads panel displays your five most recently downloaded files, along with their size and download status. To see all of your downloads at any time, go to the Library by clicking on Show all downloads at the bottom of the Downloads panel.

How do I force a file to open in browser instead of downloading Firefox?

Click on the '''Downloads''' icon in the toolbar (it should automatically open when you download a file). 2. Right-click on the file and enable '''Always Open Similar Files''' 3. Go to '''Settings''', and scroll down to the ''Applications'' section 4.

How do I use Firefox File Manager?

Head over to the Firefox Add-on page File Manager Firefox add-on. Install the File Manager add-on by clicking the + Add to Firefox button. If you're using Firefox for Chrome OS you may see a “this add-on does not work on your platform” message – ignore it. When prompted by Firefox, click the Add button.


Im creating a web extension and porting from XUL. I used to be able to easily read files with

  var dJsm = Components.utils.import("resource://gre/modules/Downloads.jsm").Downloads;
  var tJsm = Components.utils.import("resource://gre/modules/Task.jsm").Task;
  var fuJsm = Components.utils.import("resource://gre/modules/FileUtils.jsm").FileUtils;
  var nsiPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);

  ....

  NetUtil.asyncFetch(file, function(inputStream, status) {
           if (!Components.isSuccessCode(status)) {
            return;
           }
            var data =  NetUtil.readInputStreamToString(inputStream, inputStream.available());
            var data = window.btoa(data);
            var encoded_data_to_send_via_xmlhttp = encodeURIComponent(data);
            ...
  });

This above will be deprecated.

I can use the downloads.download() to know what was the last download but I can NOT read the file and then get the equivalent for encoded_data_to_send_via_xmlhttp

Also in Firefox 57 onwards, means that I have to try to fake a user action by a button click or something, or upload a file.

  Access to file:// URLs or reading files without any explicit user input 

isnt there an easy way to read the last downloaded file?