And was the content of file really corrupt or something like smaller than
expexcted result (data truncated)?

Maurizio Cucchiara

Il giorno 08/dic/2010 23.05, "CRANFORD, CHRIS" <chris.cranf...@setech.com>
ha scritto:
> No, behavior was the same between Firefox and IE.
> The ZIP file simply could not be opened as Explorer felt it was invalid.
>
>> -----Original Message-----
>> From: Maurizio Cucchiara [mailto:maurizio.cucchi...@gmail.com]
>> Sent: Wednesday, December 08, 2010 2:45 PM
>> To: Struts Users Mailing List
>> Subject: Re: RE: Result Type Stream Corrupted
>>
>> Did you get this behavior with different browser?
>>
>> Maurizio Cucchiara
>>
>> Il giorno 08/dic/2010 19.47, "CRANFORD, CHRIS"
>> <chris.cranf...@setech.com>
>> ha scritto:
>> > Found the culprit, but it doesn't make any sense to me.
>> >
>> > This one particular page was triggering the export by using a GET
>> operation. The other pages where it was working fine was using
>> javascript to
>> set a form value and then submitted the form to the action, inevitably
>> doing
>> a POST operation instead.
>> >
>> > Why would GET vs POST make a difference in this case?
>> >
>> >> -----Original Message-----
>> >> From: Maurizio Cucchiara [mailto:maurizio.cucchi...@gmail.com]
>> >> Sent: Wednesday, December 08, 2010 12:14 PM
>> >> To: Struts Users Mailing List
>> >> Subject: Re: Result Type Stream Corrupted
>> >>
>> >> In my experience this kind of issue usually depends on the content
>> >> length value.
>> >> As far I can recall, you should be able to monitor net activity
>> >> through firebug. Check that content length is equal to the
> effective
>> >> file size.
>> >>
>> >>
>> >> 2010/12/8 CRANFORD, CHRIS <chris.cranf...@setech.com>:
>> >> >
>> >> > I have several actions in my application where a user can click
> an
>> >> > export option on the page and the content that was rendered to
> the
>> >> > screen gets formatted in a file, zipped, and then streamed to the
>> >> client
>> >> > browser using the stream result type. The problem is that for
> one
>> >> > particular page, the result seems to be corrupted and the zip
> file
>> >> > cannot be opened, but the same code seems to work in other
>> actions.
>> >> >
>> >> > public class BaseAction extends ActionSupport
>> >> > {
>> >> > private InputStream downloadStream;
>> >> > private String downloadFileName;
>> >> > private String downloadContentType;
>> >> > private long downloadBufferSize;
>> >> > private long downloadFileSize;
>> >> >
>> >> > // getter/setters
>> >> > }
>> >> >
>> >> > public class SupplierAction extends BaseAction
>> >> > {
>> >> > public String search()
>> >> > throws Exception
>> >> > {
>> >> > if(doExport())
>> >> > {
>> >> > ByteArrayOutputStream data =
>> >> > supplierService.getExportStream(searchCriteria);
>> >> > setDownloadStream(new ByteArrayInputStream(data));
>> >> > setDownloadContentType("application/zip");
>> >> > setDownloadBufferSize(1024);
>> >> > setDownloadFileSize(data.size());
>> >> > setDownloadFileName("suppliers.zip");
>> >> > return "download";
>> >> > }
>> >> >
>> >> > vendorList = supplierService.getSearch(searchCriteria);
>> >> > // return to render jsp
>> >> > return SUCCESS;
>> >> > }
>> >> > }
>> >> >
>> >> > In our struts.xml file, I simply defined "download" as a global
>> >> result
>> >> > definition so that all of our applications could easily handle
>> >> passing
>> >> > downloadable content back to the browser if coded. Here's the
>> >> > definition
>> >> >
>> >> > <global-results>
>> >> > <result name="download" type="stream">
>> >> > <param name="inputName">downloadStream</param>
>> >> > <param name="contentType">${downloadContentType}</param>
>> >> > <param name="bufferSize">${downloadBufferSize}</param>
>> >> > <param name="contentLength">${downloadFileSize}</param>
>> >> > <param name="contentDisposition">attachment;
>> >> > filename="${downloadFileName}"</param>
>> >> > </result>
>> >> > </global-result>
>> >> >
>> >> > My initial thought was that the ZIP file was being damaged. I
>> >> checked
>> >> > in the service layer by having my byte array written to a file on
>> >> disk,
>> >> > the file contents were fine and could be opened locally.
> Secondly
>> I
>> >> > performed the same test in the action in the event there was a
>> >> problem
>> >> > handing the data back to the action layer. The contents written
>> to
>> >> disk
>> >> > from the action layer were also fine.
>> >> >
>> >> > Anyone have any ideas what could be my problem????
>> >> >
>> >> >
>> >> >
>> >> >
> ------------------------------------------------------------------
>> ---
>> >> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> >> > For additional commands, e-mail: user-h...@struts.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Maurizio Cucchiara
>> >>
>> >>
> --------------------------------------------------------------------
>> -
>> >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> >> For additional commands, e-mail: user-h...@struts.apache.org
>> >>
>> >
>> >
>> >
>> >
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> > For additional commands, e-mail: user-h...@struts.apache.org
>> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

Reply via email to