首页 > 解决方案 > Spring Webflux - 文件上传大小限制(spring.servlet.multipart.max-file-size 不起作用)

问题描述

有文件上传大小FilePart吗?这不起作用:我将其设置为 100B,但我可以上传 8KB 的文件。

spring:
  servlet.multipart: # see MultipartProperties
    max-file-size: 100B
    max-request-size: 200B

我知道这是针对多部分的,但我使用的是 FilePart:

    @PostMapping(value = "/{id}/draft/target", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseStatus(OK)
    public Mono<TargetsValidationResponse> uploadTargets(@PathVariable("id") ObjectId id, @RequestPart(name = "file") Mono<FilePart> file) {
        return file.flatMap(parser::parseTargets)
                .zipWith(promotionServiceAdapter.getDraft(id))
                ...;
    }

标签: javaspring-bootspring-webflux

解决方案


推荐阅读