Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda