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中指定的参数名不一致接口发布方也能接收到