1

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 ?

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243

1 Answers1

0

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.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • I have already tried using pell parser but it seems I am missing out some more required configuration. I have included the plugin file in the /WEB-INF/lib directory followed by entry in struts.xml. But I cannot upload the larger files (>2 GB). – p_saurabh92 Dec 10 '15 at 11:07
  • Have you read the **BOLD** part ? The pell parser doesn't allow you to upload files larger than 2gb. **The jakarta-stream does**. And it's available from 2.3.18+ (that is not released into the wild, so from 2.3.20+). [Just migrate to 2.3.24.1](http://struts.apache.org/downloads.html) and live happy – Andrea Ligios Dec 10 '15 at 11:09
  • Is there any other alternative to this issue where I do not have to migrate from struts 2.1.8 to 2.3.18+ ? I used pell parser going by the link (https://struts.apache.org/docs/handling-file-uploads.html) , which says for the struts.multipart.maxSize element that it can be set as high as 2 Gigabytes (higher if you want to edit the Pell multipart source but you really need to rethink things if you need to upload files larger then 2 Gigabytes!) – p_saurabh92 Dec 10 '15 at 11:27
  • I don't think so, unless you want to rewrite that parser and customizing your version of the library. But consider that newer versions has a lot of improvements and security fixes, so consider seriously to migrate. – Andrea Ligios Dec 10 '15 at 15:30
  • Migrating a large project from 2.1.8 to 2.3.18 + would have many dependencies. I tried replacing the jar files in the WEB-INF directory of my project but the application crashed. Any other changes required? – p_saurabh92 Dec 11 '15 at 14:00
  • 2.1.8 is already *over* the majority of the problems that you would encounter if migrating from 2.0 to 2.3. The remaining problems are trying to avoid DMI, trying to avoid static method access, allowing action suffix in struts.xml, change validation xml files DTD from 1.0.2 to 1.0.3, but probably the whole thing is quick, no matter if the project is large or small, because most of the changes are centralized in one configuration file. BTW, ensure you're upgrading ALL the jars needed (struts core, ognl, freemarker, javassist, ecc) to the same, right, latest version – Andrea Ligios Dec 11 '15 at 14:13
  • I tried migrating to 2.3.24 but facing the following issue: http://stackoverflow.com/questions/34671001/after-migrating-to-struts-2-3-24-from-struts-2-1-8-no-response-to-action-on-log – p_saurabh92 Jan 08 '16 at 08:04
  • File upload issues in struts 2.3.24 http://stackoverflow.com/questions/34715137/after-migration-to-struts-2-3-24-file-upload-still-not-supported-for-greater-th – p_saurabh92 Jan 11 '16 at 06:25