was服务器修改open files,解决feign实现微服务间的文件上传出现错误the request was rejected because no multipart boundary was ...

在使用io.github.openfeign.form的3.0.3版本时,遇到一个问题:请求头中的Content-Type在被转换为Map时,因‘,’或‘;’导致异常。具体表现为在org.apache.tomcat.util.http.fileupload.FileUploadBase的getBoundary方法中,FileItemIteratorImpl构造时抛出异常。问题在于Content-Type被错误地分割,缺少了boundary键。解决方法是升级feign-form的版本到3.6.0,同时更新commons-fileupload为1.3.3,这能避免上述问题并正确处理Content-Type。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目最开始的依赖

io.github.openfeign.form

feign-form

3.0.3

io.github.openfeign.form

feign-form-spring

3.0.3

commons-fileupload

commons-fileupload

1.3.3

跟踪源码发现content-type会被","或";"进行转换为Map,跟踪代码为org.apache.tomcat.util.http.fileupload.FileUploadBase#getBoundary

截图

3ecbc0062411

20191217012606545.png

在org.apache.tomcat.util.http.fileupload.FileUploadBase.FileItemIteratorImpl#FileItemIteratorImpl抛出异常

3ecbc0062411

2019121701274175.png

请求头中内容为

//用户所调用的接口提交的content-type

multipart/form-data; boundary=--------------------------381278542566024683689443

//经过feign转发请求后的content-type,按英文逗号拆分刚好Map没有boundary为key的值,索引报错

multipart/form-data, multipart/form-data; charset=UTF-8; boundary=16f0f6d2c45

解决方法为修改feign-form的版本

io.github.openfeign.form

feign-form-spring

3.6.0

io.github.openfeign.form

feign-form

3.6.0

commons-fileupload

commons-fileupload

1.3.3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值