With Apache this this really easy, but with Node.JS I don't think so. Simply, I want that when a user click something like this: <a href="/dir/file.png">
, he starts to download the file. When I do that, I'm redirected to http://foo.com/fir/file.png
, and I visualize the photo. Also say that I have in the app configure this app.use(express.static(__dirname + '/public'));
, so, the file is in the public path, and the public path is declared as static. And, when the users click, I dont want that he will be redirected and then the download starts.
I know this is posible, it's just click a link and a download starts! But I don't know how to do it.
Thank's advance!
EDITED:
The HTML where is the <a href="">
for the download is here:
app.get('/:user/:id', function (req, res){
usermodel.findOne({ user: req.params.user }, function (err, user){
var imagen = user.imagen.id(req.params.id);
if (err) throw err;
res.render('photo.ejs', {
user: user,
photo: imagen,
});
});
});
Is necessary to create a new app.get
? If I do that, I would get redirected? I'm trying to do this without getting redirected.