通过feign接口上传文件时报错the request was rejected because no multipart boundary was found

  • Post author:
  • Post category:其他


通过feign接口上传文件时报错the request was rejected because no multipart boundary was found

原因是在定义feign接口时使用了@RequestParam注解,应该改为@RequestPart注解

@FeignClient(name=”DOC”, contextId = “file”)

@RequestMapping(“/doc/file”)

public interface DocApi {

@PostMapping(value=”/download”)

public Response downloadFile(@RequestParam(“fileId”) String fileId);

@PostMapping(value=”/upload”, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)

public Result<String> uploadFile(@RequestPart(value = “file”,required = true) MultipartFile file);

}



版权声明:本文为thethefighter原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。