spee.ch/server/controllers/assets/utils/serveFile.js
2018-04-29 13:00:41 -07:00

14 lines
379 B
JavaScript

const logger = require('winston');
const serveFile = ({ filePath, fileType }, res) => {
logger.verbose(`serving file: ${filePath}`);
const sendFileOptions = {
headers: {
'X-Content-Type-Options': 'nosniff',
'Content-Type' : fileType || 'image/jpeg',
},
};
res.status(200).sendFile(filePath, sendFileOptions);
};
module.exports = serveFile;