2019-07-27 01:31:28 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-04 00:24:39 +08:00
|
|
|
const getContentDisposition = require('../../utils/content-disposition');
|
2019-07-27 01:31:28 +08:00
|
|
|
|
|
|
|
module.exports = function content () {
|
|
|
|
return function contentMiddleware (req, res, next) {
|
|
|
|
const { filename } = res.locals.params;
|
|
|
|
const { formatter } = req;
|
|
|
|
const useInline = !req.query.format && !req.body.format && !req.query.filename && !req.body.filename;
|
|
|
|
|
|
|
|
res.header("Content-Disposition", getContentDisposition(formatter, filename, useInline));
|
|
|
|
res.header("Content-Type", formatter.getContentType());
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|