file download는 node.js의 router에서 response를 통해 쉽게 수행할 수 있다.
router.get('/download/:f', async (req, res, next) => {
res.download(req.params.f, function (error) {
if (error) {
console.log('downloadErr');
} else {
console.log('download ok!');
}
});
});
function 으로 error를 체크할 수 있다.