Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
How to make the FileSystemAPI-written file appear on the bottom as if it were downloaded?

I used to handle file downloading by creating an anchor element and clicking on it:

exports.saveBlobAsFileImpl = blob => filename => () => {
    var a = document.createElement("a");
    var url = URL.createObjectURL(blob);
    a.href = url;
    a.download = filename;
    document.body.appendChild(a);
    a.click();
    setTimeout(function(){
        document.body.removeChild(a);
        window.URL.revokeObjectURL(url);
    }, 100);
    return true;
};

(don't mind that the function is curried, it's because the function is exported to PureScript). It works nicely but the downside of it is that it is always downloaded to the default location, and the user cannot overwrite the filename given. So I turned to the new FileSystem API:

exports.saveBlobAsFileImpl = blob => filename => () => {
  window.showSaveFilePicker({ suggestedName: filename })
    .then(fileHandle => fileHandle.createWritable())
    .then(stream => {
      stream.write(blob);
      stream.close();
    })
    .catch(err => console.log("SaveFile aborted"));
    return true;
};

It also works fine (the user chooses the directory and can change the default hardcoded filename). However, now he is unable to open the file right away, as it isn't shown the way downloaded files are (on the bottom of the screen in Chrome). He has to open the file explorer on the folder he downloaded it to, and open from there.

Here is my question: can I have the advantages of both worlds, i.e. ability of the user to select a folder to which he wants to download the blob and overwrite the filename if necessary, and show the downloaded file on the bottom of the screen so the user can open it right away?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!