How can I increase maximum file upload in Vaadin - Spring Boot

645 views Asked by At

I'm trying to upload a file in Vaadin 14.4.2

        MemoryBuffer loadWeightsBuffer = new MemoryBuffer();
        Upload loadWeightsButton = new Upload(loadWeightsBuffer);
        loadWeightsButton.setMaxFiles(1);
        loadWeightsButton.setDropLabel(new Label("Load weights"));
        loadWeightsButton.setMaxFileSize(500000000);
        loadWeightsButton.addFileRejectedListener(event -> {
            writeToTerminal(event.getErrorMessage());
        });
        loadWeightsButton.addSucceededListener(event -> {
            saveFile(event.getMIMEType(), event.getFileName(), loadWeightsBuffer, WEIGHTS);
        });

But I get this error when I upload to large file.

org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (44948839) exceeds the configured maximum (10485760)

I have tried to add this in application.properties without success. How can I increase the upload size in Vaadin?

spring.http.multipart.max-file-size=500MB
spring.http.multipart.max-request-size=500MB
1

There are 1 answers

0
cfrick On BEST ANSWER

There are multiple settings and they have changed over time. For use with Springboot >= 2 and the use with a servlet container, you need to set spring.servlet.multipart (note: servlet instead of http).