Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件上传报错 DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144 #167

Closed
whiledevil opened this issue Mar 21, 2020 · 11 comments
Labels
feature: plugin type: bug Something isn't working

Comments

@whiledevil
Copy link

Spring 版本 5.2.4.RELEASE
soul 版本 2.1.2-RELEASE

FileSizeFilter 会自行创建 DataBufferDecoder,不会使用 Spring 创建的 DataBufferDecoder对象,导致spring.codec.max-in-memory-size 设置无法解决该报错问题。
这种情况该如何解决?

@yu199195
Copy link
Member

请在soul里面指定 配置文件里面加行 file.size = 100 单位是mb

@whiledevil
Copy link
Author

请在soul里面指定 配置文件里面加行 file.size = 100 单位是mb

设置成100没有用,报错上传文件并没有超过默认的10mb,报错地点是 LimitedDataBufferList 不是FileSizeFilter 的文件大小判断。

@yu199195
Copy link
Member

目标接口的的controller写法,不是 File接收吗

@whiledevil
Copy link
Author

目标接口的的controller写法,不是 File接收吗

接口代码如下

@RequestMapping("/upload")
@SoulClient(path = "/file/upload", desc = "文件上传接口")
public ResponseMap fileUpload(@RequestParam("file") MultipartFile file, @RequestParam(value = "caseId", required = false) Long caseId) throws IOException, BizException {
    return fileService.upload(file, caseId);
}

@yu199195
Copy link
Member

那应该没问题的,postMan 测试下,是不是通过body,设置了file上传模式

@whiledevil
Copy link
Author

whiledevil commented Mar 23, 2020

那应该没问题的,postMan 测试下,是不是通过body,设置了file上传模式

降级 Spring 版本到 5.2.0.RELEASE 就不会有该问题。
5.2.0.RELEASE以上所有版本都会报错。
与下面问题应该是同一个原因,但我无法通过修改 FileSizeFilter 中的 messageReaders,来解决该问题。
spring-projects/spring-framework#23961

@chyhub
Copy link

chyhub commented May 20, 2020

那应该没问题的,postMan 测试下,是不是通过body,设置了file上传模式

降级 Spring 版本到 5.2.0.RELEASE 就不会有该问题。
5.2.0.RELEASE以上所有版本都会报错。
与下面问题应该是同一个原因,但我无法通过修改 FileSizeFilter 中的 messageReaders,来解决该问题。
spring-projects/spring-framework#23961
大佬,你上传还有问题吗?我遇到个io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1 的问题,你上传没遇到吗

@yu199195
Copy link
Member

已经在master修护

@yu199195 yu199195 added type: bug Something isn't working feature: plugin labels Sep 2, 2020
@yu199195 yu199195 closed this as completed Sep 2, 2020
@gaoweicong
Copy link

这个问题解决了吗? 在 2.2.1版本还是会报错

@dengliming
Copy link
Member

master上面修复了的 可以试下 还没发release版本

@leohou0430
Copy link
Contributor

use master branch code, it's still throw exception.
Exceeded limit on max bytes to buffer : 262144

yu199195 pushed a commit that referenced this issue Mar 1, 2021
* fix #167 modify file size limit

* fix #167 modify file size limit

Co-authored-by: leo.hou <leo.hou@huolala.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: plugin type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants