I’m creating some APIs, and one of that is to download a excel file which is created by Phoenix with the elixlsx library. I’ve succeeded to create the Excel File.
However, after that, when I response that file to front-end via Browser,
I can not get the file with a specified file name which is given by my code.
I can get the file with like “clients-1552475772585.xls”, because the controller name is ClientsController ( filename is clients_controller.ex).
How can I get ( download ) the file with a filename I expected ?
When I respond, I tried send_resp, send_file and send_download, but I always get the file with filename is “clients-1552475772585.xls”.
Is followed by a string containing the original name of the file transmitted. The filename is always optional and must not be used blindly by the application: path information should be stripped, and conversion to the server file system rules should be done. This parameter provides mostly indicative information. When used in combination with Content-Disposition: attachment , it is used as the default filename for an eventual “Save As” dialog presented to the user.
Edit: Like to add that if you are in total control (it’s not something that user can effect) of Content-Disposition filename then you don’t need to escape or do any of that.