spee.ch/server/controllers/assets/utils/serveFile.js
2018-05-07 11:03:30 -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;