0

我正在尝试在 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);
        });

但是当我上传到大文件时出现此错误。

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

我试图添加它application.properties但没有成功。如何增加 Vaadin 中的上传大小?

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

1 回答 1

4

有多种设置,它们随着时间的推移而变化。对于 Springboot >= 2 和 servlet 容器使用,需要设置spring.servlet.multipart(注意:servlet代替http)。

于 2020-11-21T23:07:57.357 回答