0

I created a downloadable file in my web page using Javascript and nodejs. The problem is that when the user tries to download it, it takes forever to start the download and when it does it instantly downloads the file. What I want to do, is to show to the user the progress of the download, like in the image below enter image description here

in the server side I just serve the static file using express

const express = require('express')
const app = express()
app.use(express.static('app'));

app.listen(port, () => {
    console.log(`Example app listening at http://${serverIp}:${port}`)
});

in the client side I GET request the file

export const getAppFile = () => {
    return fetch("build/localServer.exe", {
        method: 'GET',
        'content-disposition': 'attachment',
        'content-type': 'application/octet-stream',
      })
      .then((response) => response.blob());
}
  • Does this answer your question? [Detect when a browser receives a file download](https://stackoverflow.com/questions/1106377/detect-when-a-browser-receives-a-file-download) – benjm Jan 21 '22 at 17:53

1 Answers1

0

The download progress is handled by the clients computer. I don't think the computer talks to the browser on the progress. You may want to try something like this: https://stackoverflow.com/a/4168965/15263184

benjm
  • 57
  • 1
  • 14