I have web project I which I am using Struts2 framework. In this people uploads the pdf file, for that I have used struts File upload API.
But the strange this, every second file upload is corrupted on server, when I try to open file, it gives me error:
There was an error opening this document. The file is damaged and could not be repaired.
I have used the following code as xml configuration:
<constant name="struts.multipart.maxSize" value="314572800" />
<action name="uploadData" class="com.lufthansa.ereader.web.action.PublisherAction" method="uploadData">
<interceptor-ref name="basicStack"/>
<interceptor-ref name="validation"/>
<interceptor-ref name="workflow"/>
<interceptor-ref name="redirectMessage" />
<interceptor-ref name="paramsPrepareParamsStack" />
<result name = "success" type="redirectAction" >publisherDashBoard.action</result>
<result name="error" type="redirectAction">publisherDashBoard.action</result>
<result name="input" type="redirectAction">publisherDashBoard.action?error=true</result>
</action>
I have also used multipart form data also..
<s:form name = "uploadContent" action="/publisher/uploadData.action" method="post" enctype="multipart/form-data" theme="simple">
Now I am confused, why this problem could be ?
Do struts handle the partial upload of file in case of connection loss or something?
Or this problem is due to some other reason, that file are getting corrupted.
How do I handle these cases of file getting corrupted.
I have seen this problem is reported by some other people also, here is the reference threads http://www.coderanch.com/t/50100/Struts/Uploaded-files-incomplete http://grokbase.com/t/struts/user/112sjfg6eg/file-upload-issue http://web.archiveorange.com/archive/v/FLO18lz72HB5mKGyEfKT