1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

fix: Fix attachment headers

Closes #231
This commit is contained in:
Maksim Eltyshev 2022-04-29 17:21:39 +05:00
parent c2c1ccbefe
commit 7eb799006d
2 changed files with 7 additions and 11 deletions

View file

@ -61,7 +61,9 @@ module.exports = {
throw Errors.ATTACHMENT_NOT_FOUND;
}
this.res.setHeader('Content-Disposition', `inline; ${inputs.filename}`);
this.res.type(attachment.filename);
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
return exits.success(fs.createReadStream(filePath));
},
};

View file

@ -14,10 +14,6 @@ module.exports = {
regex: /^[0-9]+$/,
required: true,
},
filename: {
type: 'string',
required: true,
},
},
exits: {
@ -56,14 +52,12 @@ module.exports = {
throw Errors.ATTACHMENT_NOT_FOUND;
}
let contentDisposition;
if (attachment.isImage || path.extname(attachment.filename) === '.pdf') {
contentDisposition = 'inline';
} else {
contentDisposition = `attachment; ${inputs.filename}`;
this.res.type(attachment.filename);
if (!attachment.isImage && path.extname(attachment.filename) !== '.pdf') {
this.res.set('Content-Disposition', 'attachment');
}
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
this.res.setHeader('Content-Disposition', contentDisposition);
return exits.success(fs.createReadStream(filePath));
},
};