I\'ve built a node/express website for my university project that, after searching for an ID of a law, it shows a big table with all files in different formats and languages
In Express 4 and later, there are 2 helper functions to change the content-type and specify attachment disposition:
res.type("application/octet-stream");
res.attachment("filename.ext");
See docs for type and attachment.
You need to add a new header to the response object to indicate the file name and do a regular download.
res.set("Content-Disposition", "attachment;filename=somefile.ext");
You could also use "inline" if instead you want the browser to try to open the file within it self, like with Chrome does with pdf files.
res.set("Content-Disposition", "inline;filename=somefile.ext");
As per @Thomas suggestion, also is a good idea to include always the right content type:
res.set("Content-Type", "application/octet-stream");