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.
|Published (Last):||23 June 2015|
|PDF File Size:||8.98 Mb|
|ePub File Size:||17.87 Mb|
|Price:||Free* [*Free Regsitration Required]|
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.
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 byteFileInputStream or String value. Learn more about retrieving config values.