/**
* @author: wangjun
* @create: 2018/9/26
**/
@FeignClient(value = "graphic-client", url = "${graphic.url}")
public interface GraphicClient {
/**
* 查看流程图
*
* @param orderId
*/
@RequestMapping(value = "/v3/workflow/graphics", method = RequestMethod.GET,
consumes = MediaType.IMAGE_PNG_VALUE)
Response getGraphics(@RequestParam("orderId") Long orderId);
}
注意:Response 为
import feign.Response;
@GetMapping(value = "/v1/orders/{orderId}/flow-chart",
produces = MediaType.IMAGE_PNG_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void getGraphics(@PathVariable Long orderId, HttpServletResponse response) {
Response.Body feignResponse = GraphicsClient.getGraphics(orderId);
try (InputStream inputStream = feignResponse.asInputStream();
ServletOutputStream outputStream = response.getOutputStream()) {
response.setContentType("image/png");
outputStream.write(IOUtils.toByteArray(inputStream));
} catch (Exception e) {
throw new ClientException("get credit-order graphics fail :{} ", e);
}
}
文件下载就不说了,网上案例太多