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: Shasho Mazull
Country: Uganda
Language: English (Spanish)
Genre: Photos
Published (Last): 23 June 2015
Pages: 322
PDF File Size: 8.98 Mb
ePub File Size: 17.87 Mb
ISBN: 970-9-40955-668-9
Downloads: 76475
Price: Free* [*Free Regsitration Required]
Uploader: Arakasa

I probably came across the same post Other than that, so far things are ok. You can fix this by adding CompileStatic to your method, but that is not always feasible. This will also set a response header with the name Content-Disposition with a the filename as value.

The Grails Framework

Grails will try to find the content type based on the extension of the filename. On Wed, Jul 30, at 9: Does anyone have any suggestions for me? Your email address will not be published. Leave a Reply Cancel reply Your email address will not be published. Are you facing any problems with that?


Newer Post Older Post Home.

Grails User (Old Archive) – Proper way to stream file from controller

Posted by Hubert Klein Ikkink. Hi all, I have a controller which would stream file as response. If I recall correctly, the left shift operator here uses some annotation or something clearly I don’t remember details! Sign up using Facebook. Dynamic Productivity for the Java Developer’, author: Notify me ouyputstream new posts by email. Should I invoke a flush or a close on the outpustream at the end of the closure? I also typed the methods as void perhaps I am still too Java-fussy?

If that’s the case, copy from stream to stream.

Proper way to stream file from controller

In the following controller we find an image in our application using grailsResourceLocator. The code now appears as response. Thanks If you are using Grails 2, just change the setConfiguration part to this: In a controller I have a method that appends a string to the response.

Email Required, but never shown. GrailsConfigurationAware import static org. Post Resoonse Answer Discard By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies.


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

September 5, Grails Goodness: Handler dispatch failed; nested exception is java. Notify me of follow-up tesponse by email. This is nice and clean and works just fine.

I believe I’ve read somewhere that I might be able to cure this problem by replacing Tomcat7 with Tomcat8; however right now I’m running Ubuntu I was tired of my clients asking me how to import a CSV in Excel. I’m glad it was useful to you, and thanks for the additional info for anybody else who needs this!

A CSV file is easy to import in Excel. Generally things are working but today we ran across a problem that seems to be shared by others but I cannot find a solution. The file attribute can be assigned a byte[]FileInputStream or String value. Learn more about retrieving config values.