I have a .gz file located at /public/files/update.tar.gz
. I would like to serve it for downloading using the route /ud/files/update.tar.gz
. I would like to do it as static content and also with route (as some files will have a dynamic generated route).
I've tried the following for static (Actually achieved with nginx wich maybe is even better):
main.use('/ud/files', express.static(path.join(__dirname, 'public/files')));
Here I get the error:
Error: No default engine was specified and no extension was provided. at new View (bla bla)
And for dynamic url at /ud/files/tX2r8z/update.tar.gz:
router.get('/ud/files/:s/:file', function(req, res) {
checkSg(req.params.s, function(err) {
if(!err) {
res.download("/public/files/" + req.params.file, req.params.file); 'also tried sendFile()
} else {
res.send(404);
}
});
});
Here I get two errors toghether:
Error: Forbidden at SendStream.error (bla bla)
Error: No default engine was specified and no extension was provided. at new View (bla bla)
Any ideas?