wt., 30 wrz 2025 o 21:21 Ute Kaiser <[email protected]> napisał(a):
> I want to add some comments here about the somehow misleading documentation 
> on this.
> >>
> Files Number Limit
>
> Since Struts 6.1.2 a new option was added, which uses Commons FileUpload 
> feature to limit how many files can be uploaded at once, in one request. This 
> option requires to use Commons FileUpload ver. 1.5 at least and by default is 
> set to 256. Please always set this to a finite value to prevent DoS attacks.
> To change this value define a constant in struts.xml as follows:
> <struts>
>     <constant name="struts.multipart.maxFiles" value="500"/>
> </struts>
> <<
>
> Today, I used
> <constant name="struts.multipart.maxFiles" value="3"/>
> because I have 3 file upload tags on my mask.
> But the application crashed, even with only one file upload,  till I found a 
> debug message in wildfly server.log
> >>
> 2025-09-30 15:14:22,443 DEBUG 
> [org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest] (default 
> task-2) Applies max size: xxx to file upload request
> 2025-09-30 15:14:22,443 DEBUG 
> [org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest] (default 
> task-2) Applies max files number: 3 to file upload request
> 2025-09-30 15:14:22,443 DEBUG 
> [org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest] (default 
> task-2) Applies max size of single file: xxx to file upload request
> 2025-09-30 15:14:22,483 DEBUG 
> [org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest] (default 
> task-2) Error parsing the multi-part request!: 
> org.apache.commons.fileupload2.core.FileUploadFileCountLimitException: 
> attachment
>     at 
> deployment.resy.ear//org.apache.commons.fileupload2.core.AbstractFileUpload.lambda$parseRequest$1(AbstractFileUpload.java:465)
>     at 
> deployment.resy.ear//org.apache.commons.io.function.IOIterator.forEachRemaining(IOIterator.java:77)
>     at 
> deployment.resy.ear//org.apache.commons.fileupload2.core.AbstractFileUpload.parseRequest(AbstractFileUpload.java:462)
>     at 
> deployment.resy.ear//org.apache.commons.fileupload2.jakarta.servlet6.JakartaServletFileUpload.parseRequest(JakartaServletFileUpload.java:117)
>     at 
> deployment.resy.ear//org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest.processUpload(JakartaMultiPartRequest.java:51)
> <<
> Debugging org.apache.commons told me that all my parameters counted, not only 
> the fileupload parameter.

Thanks for pointing this out, I can update the docs only as we base on
what Commons Fileupload provides
https://commons.apache.org/proper/commons-fileupload/commons-fileupload2-core/apidocs/org/apache/commons/fileupload2/core/AbstractFileUpload.html#setFileCountMax(long)


Cheers
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to