13

I'm trying to upload a 6MB file to my JHipster app server. However, I get the following error. Where can I find the related configuration?

io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 10485760
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2332)
at org.xnio.channels.Channels.readBlocking(Channels.java:294)
at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:192)
at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:168)
at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:213)
at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:792)
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
user1723583
  • 553
  • 1
  • 6
  • 18

6 Answers6

19

Spring Boot has the following default properties

spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.

10485760 = 10MB

See the file upload Spring Boot guide :

Anton N
  • 2,317
  • 24
  • 28
6

For Spring Boot 1.5.13.RELEASE try this properties:

spring.http.multipart.max-request-size=100MB
spring.http.multipart.max-file-size=100MB
maslbl4
  • 136
  • 2
  • 8
2

At container level, there is the property maxPostSize which can be specified directly on the connector.

From docs:

The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

NiVeR
  • 9,644
  • 4
  • 30
  • 35
1

In addition to maslbl4 answer, for those who uses " .yml " configuration file like me, use the following code :

spring:
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB

It worked fine for me .

-1

open standalone-full.xml file and write {max-post-size="50000000"} here i give the file size 50mb. and my project is running sucessfully.

         <server name="default-server">
            <http-listener name="default" max-post-size="50000000" socket-binding="http" redirect-socket="https" enable-http2="true"/>
            <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <http-invoker security-realm="ApplicationRealm"/>
            </host>
        </se
-1

Using Spring Version :2.3.12 You can use the below properties.

spring.servlet.multipart.max-file-size=35MB
spring.servlet.multipart.max-request-size=35MB

Note :http is depricated

rahulnikhare
  • 1,362
  • 1
  • 18
  • 25