mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
parent
c2c1ccbefe
commit
7eb799006d
2 changed files with 7 additions and 11 deletions
|
@ -61,7 +61,9 @@ module.exports = {
|
||||||
throw Errors.ATTACHMENT_NOT_FOUND;
|
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));
|
return exits.success(fs.createReadStream(filePath));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,6 @@ module.exports = {
|
||||||
regex: /^[0-9]+$/,
|
regex: /^[0-9]+$/,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
filename: {
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exits: {
|
exits: {
|
||||||
|
@ -56,14 +52,12 @@ module.exports = {
|
||||||
throw Errors.ATTACHMENT_NOT_FOUND;
|
throw Errors.ATTACHMENT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
let contentDisposition;
|
this.res.type(attachment.filename);
|
||||||
if (attachment.isImage || path.extname(attachment.filename) === '.pdf') {
|
if (!attachment.isImage && path.extname(attachment.filename) !== '.pdf') {
|
||||||
contentDisposition = 'inline';
|
this.res.set('Content-Disposition', 'attachment');
|
||||||
} else {
|
|
||||||
contentDisposition = `attachment; ${inputs.filename}`;
|
|
||||||
}
|
}
|
||||||
|
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));
|
return exits.success(fs.createReadStream(filePath));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue