firefoxdesktopwebapishowsavefilepicker

showSaveFilePicker not in Firefox - what can I use instead?


With great surprise I found out that FF does not support window.showSaveFilePicker.

caniuse-showSaveFilePicker

What could I use in FF to allow saving a file from the browser programmatically?

Maybe can someone explain what reasons has FF for not supporting this feature?


Solution

  • Assuming you're working with blobs under ~2GB you can always use a classic:

    async function downloadBlob(inputblob) {
      const downloadelem = document.createElement("a");
      const url = URL.createObjectURL(inputblob);
      document.body.appendChild(downloadelem);
      downloadelem.src = url;
      downloadelem.click();
      downloadelem.remove();
      window.URL.revokeObjectURL(url);
    }
    downloadBlob(yourblob);
    This will invoke the user's preference of whether to download the file directly to a folder or to select a place in which to put it. As far as I'm aware there is no other method to invoke a file picker if the user has it left at the default which in most cases is to download without confirmation.

    Answering your question regarding why Firefox doesn't support it, Mozilla doesn't believe that the File System Access specification, which this endpoint is a part of, is a good addition to the web. You can read more here.