Hi @Mathieu_Breton Thank you for your feedback!
I just tried this, with a User
model, it seems it works (using POST
):
// In file `forest/user.js`, don't forget "download true".
{ name: 'Generate invoice', download: true },
// In a `routes/user.js`
router.post(
'/actions/generate-invoice',
permissionMiddlewareCreator.smartAction(),
(req, res, next) => {
let options = {
root: __dirname + '/../public/',
dotfiles: 'deny',
headers: {
'Access-Control-Expose-Headers': 'Content-Disposition',
'Content-Disposition': 'attachment; filename="favicon.png"'
}
};
let fileName = 'favicon.png';
res.sendFile(fileName, options, (error) => {
if (error) { next(error); }
});
});
Could you share a simplified version of the code in your smart action definition and route? Maybe there is something missing.