Yatin Baraiya
Yatin Baraiya

Reputation: 91

Not able to upload 2gb size file with struts 2.0 frmework

Now days all latest browser, support 2 gb size limit for file upload process, Right now we are using following in our application Java, JSP, Struts 2.0 framework , we did not able to upload 2gb size file, so i have search in net, i am able to find struts.multipart.maxSize property configuration in struts.xml, i have set this value up to 2gb size, i have also set maxPostSize size property in tomcat server.xml file for increase postdata size with request.

Still we did not able to upload 2gb size file from browser.

Please some one advice us, is there any setting available in Apache server, tomcat, struts or browser, then let us know about those.

We are not using fileUpload interceptor in our file upload action

<action name="fileUpload" method="fileUpload" class="fileUploadAction">
<interceptor-ref name="check">
</interceptor-ref>
<result name="Errorjsp">tFrame.jsp</result>
<result name="insert">FileFrame.jsp</result>
</action>

and our java side action have flat logic of upload , there is no filesize limit validation at server side code.

i want to know the reasons why large file did not upload?

for more update , we found that issue creating in our environment is CDN network. Client request through browser to send file to cdn network , and then cdn network send those file to actual server.

Issue only happen due to cdn network when we request of more than 2 gb size file,so it is not related to browser issue.

Issue not happen with cdn network , when we send out file byte to chunk to cdn network,means when we send chunk request of file byte using one java demo program. so from this analysis, we can say that cdn network work properly when we send data in chunk-ed.

and in our case we sending file upload request throgh browser, so we can't send chunk-ed request, So now my question is that is any technique or mechanism available to resolve our issue Is there any js or request mechanism available , which send chunk byte request through browser? Is there any other technique available to resolve our issue?

Thanks and regards Yatin Baraiya

Upvotes: 1

Views: 1659

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50281

Struts2 lets you upload file UP TO 2GB, that is the maximum allowed size for a Request:

This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive.

To do that, you need to set both:

  1. set the common <constant name="struts.multipart.maxSize" value="2147483648" />, for the overall request size;

  2. set the FileUpload Interceptor parameter, both locally to an Action, or common to a package, for the single file maximum size:

    <interceptor-ref name="fileUpload">
        <param name="maximumSize">2147483648</param>
    </interceptor-ref>
    

The .2 is the missing piece in your configuration: currently, you are allowed to send 2 GigaBytes of stuff, but with a maximum filesize of 2 MegaBytes, eg. 1000 files of 2mb max each one.

Apply the above setting to your configuration to make it work, eg:

<action name="doUpload" class="com.example.UploadAction">
    <interceptor-ref name="defaultStack">
        <param name="fileUpload.maximumSize">2147483648</param>
    </interceptor>
    <result name="success">good_result.jsp</result>
</action>

Upvotes: 1

Related Questions