2017-07-17 13:16:11 -07:00
|
|
|
const logger = require('winston');
|
|
|
|
|
|
|
|
module.exports = {
|
2017-11-27 15:57:20 -08:00
|
|
|
serveFile ({ filePath, fileType }, claimId, name, res) {
|
2017-11-21 12:53:43 -08:00
|
|
|
logger.verbose(`serving ${name}#${claimId}`);
|
|
|
|
// set response options
|
2017-11-27 15:57:20 -08:00
|
|
|
const headerContentType = fileType || 'image/jpeg';
|
2017-11-21 12:53:43 -08:00
|
|
|
const options = {
|
2017-07-17 13:16:11 -07:00
|
|
|
headers: {
|
|
|
|
'X-Content-Type-Options': 'nosniff',
|
2017-11-21 12:53:43 -08:00
|
|
|
'Content-Type' : headerContentType,
|
2017-07-17 13:16:11 -07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
// send the file
|
2017-11-27 16:53:32 -08:00
|
|
|
res.status(200).sendFile(filePath, options);
|
2017-07-17 13:16:11 -07:00
|
|
|
},
|
2017-11-27 14:35:29 -08:00
|
|
|
showFile (claimInfo, shortId, res) {
|
2017-12-06 15:15:21 -08:00
|
|
|
res.status(200).render('show', { layout: 'show', claimInfo, shortId });
|
2017-07-31 17:02:39 -07:00
|
|
|
},
|
2017-11-27 14:35:29 -08:00
|
|
|
showFileLite (claimInfo, shortId, res) {
|
2017-12-06 15:15:21 -08:00
|
|
|
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId });
|
2017-07-31 17:02:39 -07:00
|
|
|
},
|
2017-07-17 13:16:11 -07:00
|
|
|
};
|