I'm using Node.js and I need to delete a file after user download it. Is there any way to call a callback method after pipe process ends, or any event for that purpose?
exports.downloadZipFile = function(req, res){
var fileName = req.params['fileName'];
res.attachment(fileName);
fs.createReadStream(fileName).pipe(res);
//delete file after download
};