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

220
Vistas
javascript - download a file in client's browser, then actually download the file instantly

What I actually want is to make something like Mega web, where when you download a file, first it downloads it inside your browser, then your browser prompts to actually download the file and the file will be downloaded instantly.

So far this is what I've found as a solution:

fetch(url).then(response => response.text())
  .then(uri => {
    var link = document.createElement("a");
    link.download = name;
    link.href = uri;
    link.click();
  })

while it works for small pictures, I've tried this approach on a 80mb file, and the tab crashed.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I haven't tested this yet but apparently this is working:

fetch(url)
  .then((response) => response.blob())
  .then((blob) => {
    var URL = window.URL || window.webkitURL;

    var fileURL = URL.createObjectURL(blob);

    var link = document.createElement("a");
    link.download = name;
    link.href = fileURL;
    link.click();

    URL.revokeObjectURL(fileURL);
  });
about 4 years ago · Juan Pablo Isaza Denunciar
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