传递文件
服务端
@RestController
public class DemoController {
@PostMapping("/upload")
@ApiOperation("上传文件")
public void upload(@RequestParam("file") MultipartFile file) throws Exception {
// todo
}
}
客户端
- 申明接口
主要是加上consumes = MediaType.MULTIPART_FORM_DATA_VALUE
@FeignClient
public interface IFeignService {
@PostMapping(value = "/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result upload(@RequestPart("file") MultipartFile file);
}
传递二进制流
服务端
@RestController
public class DemoController {
@PostMapping("/upload")
@ApiOperation("上传文件")
public void upload(@RequestBody byte[] bytes, @RequestParam("suffix") String suffix) {
// todo
}
}
客户端
申明接口
正常加上注解即可
@FeignClient
public interface IFeignRestService {
@PostMapping(value = "/upload")
Result upload(@RequestBody byte[] bytes, @RequestParam("suffix") String suffix);
}
标签:feign,suffix,二进制,upload,PostMapping,传递,file,public
From: https://www.cnblogs.com/fchhk-blog/p/17645792.html