0

i use feathersjs on my backend and i encountered the problem of downloading files: look to my code

app.get('/download',(req,res, next) => {
  res.sendFile(path.join(app.get('public'), 'output.xlsx'));
});

and in response of browser i see enter image description here i try to send example package.json and this is result:

enter image description here

i try to use res.download() but the result is the same. Why i can not download file on my browser?

user3127658
  • 105
  • 8

1 Answers1

0

The easiest way to save a file locally is to craft a link for the download that when clicked returns the file bytes with the Content-Disposition set to be attachment as specified in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition and the download attribute set on the anchor.

Javascript cannot save files to a users computer**

**Refer to How can JavaScript save to a local file?

Deadron
  • 4,667
  • 1
  • 15
  • 26