SpringCloud微服务Feign内部传递MultipartFile
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);
    }

 

 

FeignClient 部分

    @ApiOperation("导入运单")
    @RequestMapping(value = "/order/info/importMail", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result importMail(@RequestPart("file") MultipartFile file, @RequestParam String expressCompanyCode);
 

fegin

注意这边需要设置入参的类型()
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
并且注意这边需要使用@RequestPart注解,不能使用@RequestParam
其他参数必须加上@RequestParam注解,否则报错

 

Feign被调用服务端

    @ApiOperation("导入运单")
    @PostMapping(value = "/importMail")
    public Result importMail(@RequestParam MultipartFile file, @RequestParam String expressCompanyCode) throws Exception {
        orderInfoService.importMail(file, expressCompanyCode);
        return Result.OK("成功");
    }




 

评论区域