feign 传输文件报错 no multipart boundary was found 与 Required request part ‘file‘ is not present

org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

解决办法:升级feign-form 到3.6.0

参考:https://blog.csdn.net/wqj975005563/article/details/103572705

换了版本后异常:org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present

但是传过去的content-type是ok的

错误原因是传入的时候指定文件名字段问题

因为我是使用MockMultipartFile模拟file对象,并没有使用前端表单,所以MockMultipartFile的第一个参数一定要与接收的参数一致

服务提供者

重要:
MultipartFile multipartFile = new MockMultipartFile("file2", pdfFile.getName(),
        ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);

hello = feignHelloService.handleFileUpload(multipartFile);

与feign service中的没有关系

哪怕interface中指定的参数名不一致接口发布方也能接收到

 

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值