aa8y
aa8y

Reputation: 3942

Download file in Grails web app and display some content as well

Okay, so this is how I am downloading a file in my web app now.

try {        
    response.setContentType('application/octet-stream')
    response.setHeader('Content-Disposition', "Attachment; Filename=\"downloadFile\"")
    for (fooName in fooNames) {
        response.outputStream << getSomeBinaryDataFor(fooName).getBytes()
    }
} catch (Exception e) {
    redirect controller: 'some', action: 'where'
} finally {
    response.outputStream.close()
}

return someParamMap

And I am unable to see the the content from someParamMap. Now, I understand that it's probably because I am closing the response output stream. But is there a way I can display the content I have in someParamMap?

Upvotes: 0

Views: 233

Answers (1)

Jay Prall
Jay Prall

Reputation: 5465

No. You'll need to do this in two requests and two controller actions. One request to get the file and one to render the meta data.

Upvotes: 1

Related Questions