Multipart file maximum size configuration in Tomcat 8

Barz8 :

My application server is Tomcat and I need is to upload files (large size) to my application. The body size of POST requests is really long like 15 MB or more.

Is there any type of configuration or code I can set to overcome this problem?

Please keep in mind that this is multipart request with file upload

Many thanks in advance

ValerioMC :

Tomcat 7 and and above has a configuration called maxShallowSize that specify number of bytes for an upload with a default value of 2MB. If your application is configured to accept bigger file, for example with a MultipartResolver in Spring, Tomcat will reject the request.

Because you can configure file size in your application, my advice is to disable maxShallowSize in {TOMCAT_HOME}/conf/server.xml using value -1 and then work only with size configured in your application

as follows:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
            maxSwallowSize="-1"/>

You can find a detailed description here (with spring framerwork)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=91981&siteId=1