I have a design question regarding file upload/download which is not
completely Struts related but I was hoping someone could provide some
suggestions. I have succeeded with the upload using the struts upload
package, and then I load the file into an Oracle BLOB field. Now I need to
get it back to the user if they want to view it.
I was planning to create an Action for processing the file download. The
user will click on a URL and pass in the ID of the file as a request
parameter to the Action (i.e. fileDownload.do?id=1234). The Action will
access a session EJB which then locates the requested file and returns it to
the Action as a File object. Here is where I need advice: what is the best
way to send this File back to the browser? Can I change the response type
to "file" somehow and stream this to the browser? Another option I thought
about was saving the file to a temp directory and then redirecting the
browser to this file. I would rather not write temp files if I don't have
to. Or, is there any functionality provided with struts for sending a file
back to the browser?
Any suggestions greatly appreciated...
Thanks,
Bob