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: Nikolar Samurr
Country: Uganda
Language: English (Spanish)
Genre: Spiritual
Published (Last): 17 April 2014
Pages: 236
PDF File Size: 15.53 Mb
ePub File Size: 19.98 Mb
ISBN: 867-6-45653-284-6
Downloads: 86033
Price: Free* [*Free Regsitration Required]
Uploader: Meztitaur

The code now appears as response. If the byte arrays in your examples are large, or if the ‘download’ action is called frequently, you could run into problems.

I also typed the methods as void perhaps I am still too Java-fussy?

You can fix this by adding CompileStatic to your method, but that is not always feasible. Sign up or log in Sign up using Google.

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

Does anyone have any suggestions for me? Render Binary Output with the File Attribute. 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 Hi all, I have a controller which would stream file as response.


CSV is probably the best format to export your data from a Grails App. The file attribute can be graills a byte[]FileInputStream or String value.

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

Proper way to stream file from controller. Your email address will not be published. If I recall correctly, the left shift operator here uses some annotation or something clearly I don’t remember details!

If that’s the case, copy from stream to stream. Post as a guest Name. Lauk To unsubscribe from this list, please visit: September 5, Grails Goodness: I have found it beneficial to use some of the new ‘Groovy’ methods on rewponse File class in particular the File.

You may need to add additional method signatures so that they can be statically compiled but the concept is the same. By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Grails Programmer : How to output CSV from a Grails 3 Controller | Sergio del Amo

Responnse will also set a response header with the name Content-Disposition with a the filename as value. Will give this a shot. Learn more about retrieving config values. Outpustream If you are using Grails 2, just change the setConfiguration part to this: What happens is that whenever I access it, Firefox fires up Totem plugin which streams the file from the controller. On Wed, Jul 30, at 2: Newer Post Older Post Home.


Sign up using Facebook.

Proper way to stream file from controller

In reply to this post by Lauk Daniel. Stack Overflow works best with JavaScript enabled. Then we use the render method and the file and contenType attributes to render the image in a browser:.

Anyway, this is what I do and it works fairly well for me: Notify me of follow-up comments by email. Handler dispatch failed; nested exception is java. Dynamic Productivity for the Java Developer’, author: Posted by Hubert Klein Ikkink. I wrote a post; in Spanish though. In a controller I have a method that appends a string to the response.