file-uploadstruts2multipartlarge-file-uploadmax-size

Allow more than 2 gb file upload in struts2


I am using Struts 2.1 in my project.

In struts.xml maxsize element in my project is as follows :

<constant name="struts.multipart.maxSize" value="2147483648" />

For the file upload process,

is it possible to supersede the normal 2 Gb file limit of Struts2 ?


Solution

  • You should migrate to the latest version of Struts2.

    From 2.3.20 and above, a new MulitpartRequest implementation can be used to upload large files:

    Alternate Libraries

    The struts.multipart.parser used by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type multipart/form-data, can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser is a standard part of the Struts 2 framework needing only its required libraries added to a project. The pell parser uses Jason Pell's multipart parser instead of the Commons-FileUpload library. The pell parser is a Struts 2 plugin, for more details see: http://cwiki.apache.org/S2PLUGINS/pell-multipart-plugin.html. There was a third alternative, cos, but it was removed due to licensing incompatibilities.

    As from Struts version 2.3.18 a new implementation of MultiPartRequest was added - JakartaStreamMultiPartRequest. It can be used to handle large files, see WW-3025 for more details, but you can simple set

    <constant name="struts.multipart.parser" value="jakarta-stream" />
    

    > in struts.xml to start using it.