After updating to Tomcat 10.1.42, I started getting this error when uploading multiple files in a request:
org.apache.tomcat.util.http.fileupload.impl.FileCountLimitExceededException: attachment
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:459)
at org.apache.catalina.connector.Request.parseParts(Request.java:2650)
at org.apache.catalina.connector.Request.parseParameters(Request.java:2964)
at org.apache.catalina.connector.Request.getParameter(Request.java:1111)
How to configure max file count to avoid this error, using tomcat configuration files?
While searching in tomcat documentation/google/stackoverflow I only found references to max file size, or max parameter count, but nothing related to max file count, except for this question which is specific to Spring and has no answer.
According to this: https://github.com/spring-projects/spring-boot/issues/45881, the issue may be caused by the new defaults maxPartCount and maxPartHeaderSize which are 10 and 1024(?) (They used to be unlimited). You can update them in the server.xml as connector options.
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
maxPartCount="100"
maxPartHeaderSize="1024"
/>
I tried just changing maxPartCount to 100 and that seems to fix it for me. Still testing however, you will need to figure out what good defaults will be for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With