SpringCloud通过Feign传递MultipartFile
通过openfeign传递MultipartFile
调用服务
注意这边需要设置入参的类型()
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
/**
* 导入运单
*/
@PostMapping(value = "/importMail", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<List<AfterSaleDTO>> importMail(@RequestParam("file") MultipartFile file, @RequestParam String expressCompanyCode) throws IOException {
return orderInfoFeignClient.importMail(file, expressCompanyCode);
}
fegin
注意这边需要设置入参的类型()
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
并且注意这边需要使用@RequestPart注解,不能使用@RequestParam
@ApiOperation("导入运单")
@RequestMapping(value = "/order/info/importMail", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result importMail(@RequestPart("file") MultipartFile file, @RequestParam String expressCompanyCode);
被调用服务
@ApiOperation("导入运单")
@PostMapping(value = "/importMail")
public Result importMail(@RequestParam MultipartFile file, @RequestParam String expressCompanyCode) throws Exception {
orderInfoService.importMail(file, expressCompanyCode);
return Result.OK("成功");
}