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):||2 December 2005|
|PDF File Size:||16.53 Mb|
|ePub File Size:||12.35 Mb|
|Price:||Free* [*Free Regsitration Required]|
Stream whenever I close the window before the grailw audio file gets to play. Newer Post Older Post Home. Grails will try to determine the content type for files, but we can also use the contentType attribute to set the content type. On Wed, Jul 30, at 1: Lauk To unsubscribe from this list, please visit: The file attribute can be assigned a byteFileInputStream or String value.
In the following controller we find an image in our application using grailsResourceLocator.
Proper way to stream file from controller
On Wed, Jul 30, at 9: My code is only a little different, in that I don’t set the “Content-disposition” header and flush afterwards. Posted by Hubert Klein Ikkink. This will also set a response header with the name Content-Disposition with a the filename as value. Since Grails 2 we can render binary output with the outputstrsam method and the file attribute. Sign up using Email and Password. Sign up or log in Sign up using Google.
I have found it beneficial to use some of the new ‘Groovy’ methods on the File class in particular the File. I’m glad it was useful to you, and thanks for the additional info for anybody else who needs this! Other than that, so far things are ok.
Proper way to stream file from controller. If the byte arrays in your examples are large, or if the ‘download’ action is called frequently, you could run into problems.
In a controller I have a method that appends a string to the response. CSV is probably the best format to export your data from a Grails App. I should add that I had tried a similar approach following another Resppnse post maybe yours? Most browser will then automatically download the binary content, so it can be saved on disk.
I know we worked on this one for a while! Graails all, I have a controller which would stream file as response.
B I am using the mime type and encoding defined in application. For reference in outputtream others stumble over the same problem, I had to import groovy. Are you facing any problems with that?
Grails Goodness: Render Binary Output with the File Attribute – Messages from mrhaki