I have the following code
def fileDoc = new File(document.documentLocation);
if(fileDoc.exists()){
// force download
def fileName = fileDoc.getName();
response.setContentType("application/octet-stream")
response.setHeader "Content-disposition", "attachment; filename=${fileName}" ;
response.outputStream << fileDoc.newInputStream();
response.outputStream.flush();
return true;
}
documentLocation contains a string like "c: \ mydoc \ contains_some_long_string_with_id.pdf", for example.
I would like the user to download the file, instead viewing it from the browser. It works well on chrome, where I can download, and the file will display "save as" "contains_some_long_string_with_id.pdf"
but in firefox (last). The file name is crippled only to "contains_some_long" (without a PDF extension at the end).
How to solve this problem? The file can be csv, pdf, text, html, zip, pdf or another file.
Thank you
source
share