I’d like to provide a custom name for csv file, that is downloaded via Smart Action. Here’s my code:
const fileName = 'my_custom_filename';
res.set('Access-Control-Expose-Headers', 'Content-Disposition');
res.attachment(fileName);
res.set('Content-Type', 'text/csv; charset=utf-8');
return res.send(exportData);
Expected behavior
I expect the downloaded file to have the custom name.
Actual behavior
File is called “collectionname.csv” (leads, to be exact) no matter how I try 
Context
“express”: “~4.16.3”,
“forest-express”: “^7.5.0”,
Hi @Vasilii thank you to your feedback. Unfortunately it is not possible today. I push your request into our product board.
Hi, @Arnaud_Moncel
Turns out it’s possible 
After a number of attempts, this code seems to be working just fine:
const fileName = 'custom_filename.csv';
res.set({
'Access-Control-Expose-Headers': 'Content-Disposition',
'Content-Disposition': `attachment; filename="${fileName}"`,
'Content-Type': 'text/csv; charset=utf-8'
});
return res.send(csvData);
Hi @Vasilii all right good news!
My bad for the bad response, we have different place who export is possible(eg: table view, has-many view) and the behavior is little bit different.
I’m happy to see you find the solution.
Thank you again.
1 Like