Helper that can pipe passed file and execute callback after file piped.
npm install express-response-and-pipe
When you need to download file and remove him after downloading.
const express = require('express);
const expressPipe = require('express-response-and-pipe');
app = express();
app.use(function(req, res, next) {
const options = {
filePath: '/path/to/file'
callback: 'some callback function' // default is delete file callback
};
// File will be downloaded and callback will be fired
expressPipe(res, options);
});