Grails Programmer: How to output CSV from a Grails 3 Controller. 20 / 1 Reply def outs = Stream. = (). response. Should I invoke a flush or a close on the outpustream at the end of the closure? () or GRAILS IllegalStateException error for return the Stream # Closed. graemerocher opened this Issue on Oct 29, ยท 0 comments.

Author: Vudozahn Samugal
Country: Grenada
Language: English (Spanish)
Genre: Environment
Published (Last): 14 September 2013
Pages: 101
PDF File Size: 1.33 Mb
ePub File Size: 3.46 Mb
ISBN: 413-6-61711-151-7
Downloads: 30705
Price: Free* [*Free Regsitration Required]
Uploader: Kagajora

I know we worked on this one for a while! Newer Post Older Post Home. Lauk To unsubscribe from this list, please visit: I have found it beneficial to use some of the new ‘Groovy’ methods on the File class in particular the File.

For reference in case others fesponse over the same problem, I had to import groovy. Post as a guest Name. I have a Grails application that I have recently upgraded to 3. ServletOutputStream to make this work. You may need to add additional method signatures so that they can be statically compiled but the concept is the same.


Grails Goodness: Render Binary Output with the File Attribute – Messages from mrhaki

This is nice and clean and works just fine. The code now appears as response. We have fixed this problem in our applications by adding a static utility method:.

I believe I’ve read somewhere that I might fesponse able to cure this problem by replacing Tomcat7 with Tomcat8; however right now I’m running Ubuntu I wrote a post; in Spanish though.

Grails Programmer : How to output CSV from a Grails 3 Controller

Posted by Hubert Klein Ikkink. By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow works best with JavaScript enabled. In a controller I have a method that appends a string to the response. Sign up or log in Sign up using Google.

If I recall correctly, the left shift operator here uses some annotation or something clearly I don’t remember details! Notify me of follow-up comments by email. September 5, Grails Goodness: Thanks If you are using Grails 2, just change the setConfiguration part to this: B I am using the mime type and encoding defined in application. I was tired of my clients asking me how to import a CSV in Excel. Dynamic Productivity for the Java Developer’, author: We can use the fileName attribute to set a filename for the binary content.


A I will recommend to put the logic fetching the lines in a Service. If we run the app and call the controller we will download a CSV file as this: This will also set a response header with the name Content-Disposition with a the filename as value.

My code is only a little different, in that I don’t set the “Content-disposition” header and flush afterwards. Your email address will not be published. The file attribute can be assigned a byte[]FileInputStream or String value.

In reply to this post by Lauk Daniel. Sign up using Email and Password.