I wish the users of my webapp to download a file in c:\files space. I have written the following code to use stream result type to let the users download the file. But I get surprising errors. please help me resolve them
I'm confused; you're talking about downloading in the subject and using a stream result, but talking about uploading later.
Yes, you can set where files are uploaded to, either by configuring the underlying upload library, or simply copying the temporary file in the upload action. It doesn't matter where you download the file from, but if it's outside of the web context (or in WEB-INF) you need to stream it to the client yourself.
Joined: Jan 13, 2009
I am sorry, my uploading problem is solved. Where as in download, I get the above mentioned error.. please help
Here show that You can locat doc information from API
The following is the information from this API, which I think is enough for you.
A custom Result type for sending raw data (via an InputStream) directly to the HttpServletResponse. Very useful for allowing users to download content.
This result type takes the following parameters:
contentType - the stream mime-type as sent to the web browser (default = text/plain).
contentLength - the stream length in bytes (the browser displays a progress bar).
contentDisposition - the content disposition header value for specifing the file name (default = inline, values are typically attachment;filename="document.pdf".
inputName - the name of the InputStream property from the chained action (default = inputStream).
bufferSize - the size of the buffer to copy from input to output (default = 1024).
allowCaching if set to 'false' it will set the headers 'Pragma' and 'Cache-Control' to 'no-cahce', and prevent client from caching the content. (default = true)
contentCharSet if set to a string, ';charset=value' will be added to the content-type header, where value is the string set. If set to an expression, the result of evaluating the expression will be used. If not set, then no charset will be set on the header
These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can provide getContentType() to override that parameter for the current action.
if you do exactly as this statement, I think the problem will be sovled.
I am able to download file successfully if it is single file. But the issue comes when i try to download multiple files.
I am zipping the files and trying to downaload after creating the zipfile on the server. I would like to download without saving the zipfile on the server. Has anyone tried the same..?
Hope you guys got my question. Any help is appreciated.
Yes David. I am trying to Zip the files and download. But i wanted to send the stream back to Browser rather than storing the Zip file in to the server.
Hope you got the question now.
This i am doing because i can save some time for download file wihtout saving on the server as our client is expected to download big files.