I have been trying unsuccessfully for a while to download a CSV file to the browser in grails. I have the data in bytes and am using the following code with no luck... I have tried several options like a Render, but nothing seems to be working for me. Are there any suggestions?
response.contentType='text/csv';
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Cache-Control", "no-cache, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setCharacterEncoding("UTF-8")
response.outputStream << data.bytes
response.outputStream.flush();
Sidenote: I have successfully emailed the bytes and they open properly as a CSV file