I am using nodejs and expressjs framework to download a file 'jsonFile.json' from server.
i am using the following code
res.get('/download', function(req, res) {
res.setHeader('Content-disposition', 'attachment; filename=jsonFile.json');
res.setHeader('Content-Type', 'text/json');
res.download(__dirname + 'jsonFile.json');
}
});
But this results into a response with whole content of file.
i was expecting browser to ask me to save the file in local disk.
How do i save the file in local disk.???
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…