I was reviewing the Grails 1.1 Web Application Development book. In the section wherein we are putting in the logic for downloading files, we are given directions for updating the FileController. As is, it will not work quite properly in Firefox (on Windows, anyway) when downloading files with embedded spaces in their names. The fix is quite simple. Here is the line as specified on page 149:
response.setHeader("Content-Disposition", "attachment; filename=${file.downloadName}")
Changing this to:
response.setHeader("Content-Disposition", /attachment; filename="${file.downloadName}"/)
will assure that the proper file name is used. Here I used Groovy's slashy strings and surrounded the filename in double quotes. This fix was tested not only in Firefox, but also IE, Google Chrome, Opera and Safari, all on Windows XP.
No comments:
Post a Comment
Thank you for your feedback