feign获取outstream_Spring Cloud Feign接口返回流
身无彩凤双飞翼,心有灵犀一点通。
服务提供者
@GetMapping("/{id}")
public void queryJobInfoLogDetail(@PathVariable("id") Long id, HttpServletResponse response) {
File file = new File("xxxxx");
InputStream fileInputStream = new FileInputStream(file);
OutputStream outStream;
try {
outStream = response.getOutputStream();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = fileInputStream.read(bytes)) != -1) {
outStream.write(bytes, 0, len);
}
fileInputStream.close();
outStream.close();
outStream.flush();
} catch (IOException e) {
log.error("exception", e);
}
}
client 客户端
@GetMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
feign.Response queryJobInfoLogDetail(@PathVariable("id") Long id);
服务消费者
@GetMapping("/{id}")
public void queryJobInfoLogInfoList(@PathVariable("id") Long id, HttpServletResponse servletResponse) {
Response response = apiServices.queryJobInfoLogDetail(id);
Response.Body body = response.body();
InputStream fileInputStream = null;
OutputStream outStream;
try {
fileInputStream = body.asInputStream();
outStream = servletResponse.getOutputStream();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = fileInputStream.read(bytes)) != -1) {
outStream.write(bytes, 0, len);
}
fileInputStream.close();
outStream.close();
outStream.flush();
} catch (Exception e) {
}
}
feign获取outstream_Spring Cloud Feign接口返回流相关推荐
- feign 序列化_Spring Cloud Feign 配置 FastJson
如今,越来越多的Spring MVC项目都选择使用FastJson做为Json解析框架,并且都会添加类似如下配置以支持FastJson: @Configuration public class Web ...
- Spring Cloud Feign原理详解
目录 1.什么是Feign? 2.Open Feign vs Spring Cloud Feign 2.1.OpenFeign 2.2.Spring Cloud Open Feign 3.Spring ...
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
在spring Cloud Netflix栈中,各个微服务都是以HTTP接口的形式暴露自身服务的,因此在调用远程服务时就必须使用HTTP客户端.我们可以使用JDK原生的URLConnection.Ap ...
- feignclient注解使用_从 Feign 使用注意点到 RESTFUL 接口设计规范
最近项目中大量使用了Spring Cloud Feign来对接http接口,踩了不少坑,也产生了一些对RESTFUL接口设计的想法,特此一篇记录下. SpringMVC的请求参数绑定机制 了解Feig ...
- Spring Cloud —— Feign 实现服务调用
引言 本篇博客简单介绍 Feign 的基础知识和基本应用,以前一篇博客<Spring Cloud Alibaba--Nacos实现服务治理>为代码基础,实现更简单的微服务调用方式. 一.什 ...
- Spring Cloud Feign使用详解
通过前面两章对Spring Cloud Ribbon和Spring Cloud Hystrix的介绍,我们已经掌握了开发微服务应用时,两个重要武器,学会了如何在微服务架构中实现客户端负载均衡的服务调 ...
- Spring Cloud Feign 请求时附带请求头
Spring Cloud Feign 请求时附带请求头 问题描述 解决方案 FeignConfiguration 使用 配置修改 问题描述 Feign 在请求时是不会将 request 的请求头带着请 ...
- Spring Cloud Feign传输Header,并保证多线程情况下也适用
Spring Cloud Feign传输Header,并保证多线程情况下也适用 一.现象 微服务在生产中,常遇到需要把 header 传递到下一子服务的情况(如服务A访问服务B的接口,需要传递head ...
- 通过Feign实现Spring Cloud微服务调用
我们在上一篇文章通过restTemplate实现Spring cloud微服务的调用中介绍了spring cloud微服务的一种调用方式,本文我们介绍另一种调用spring cloud微服务的方式-- ...
最新文章
- 线段树分裂与合并 ---- 树上差分 P4556 [Vani有约会]雨天的尾巴 /【模板】线段树合并
- 使用Spring 3的@value简化配置文件的读取
- python可以做什么毕业设计-Python
- 常用的CSS属性的英文单词总结及用法、解释
- 成功部署SD-WAN策略应注意的几个事项—Vecloud微云
- linux centos 7安装 apache php 及mariadb
- QT的QLocale类的使用
- Linux:驱动程序直接编译到内核(源自国嵌的视频教学)
- SVN客户端与服务端安装详解
- UVa 1605 - Building for UN
- python儿童入门视频-Python入门视频课程
- ArcGIS 判断坐标系是否正确
- 同步与异步、异步与回调
- mysql 全文所有_MySQL中的全文搜索
- 小程序定位并获取城市编码
- 前端面试之浏览器安全
- php搭建聊天室,php聊天室_用PHP MySQL搭建聊天室
- word文档更新目录为什么更新不了?
- PBS常用基本命令------PBS入门
- CH341应用升级为CH347软硬件注意事项
热门文章
- 解决HP ProLiant DL380 G5的Centos 7安装与启动不能识别硬盘问题
- 基于DotNet构件技术的企业级敏捷软件开发平台 - AgileEAS.NET - ActiveXForm运行容器...
- div背景透明内容不透明与0.5PX边框兼容设置
- 时空大数据实践之GeoWave安装部署实践
- hibernate 使用别名查询
- Android 学习 笔记_05. 文件下载
- 归纳一下:C#线程同步的几种方法
- 强制将IE,Chrome设置为指定兼容模式来解析
- C/C++基础语法复习(三):C++重载函数,多态,虚函数
- 一般是一个较为复杂的 飞鸽传书 对象