身无彩凤双飞翼,心有灵犀一点通。

服务提供者

@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) { }
}

Spring Cloud Feign接口返回流的更多相关文章

  1. spring cloud feign 接口继承以及参数传递的问题

    1. 优势     可以使用maven 进行访问,实现代码的共享,减少跨服务调用服务编写的问题   2. 使用      定义接口 publicinterfaceIUserService{ @Requ ...

  2. Spring Cloud Feign 在调用接口类上,配置熔断 fallback后,输出异常

    Spring Cloud Feign 在调用接口类上,配置熔断 fallback后,出现请求异常时,会进入熔断处理,但是不会抛出异常信息. 经过以下配置,可以抛出异常: 将原有ErrorEncoder ...

  3. Bug集锦-Spring Cloud Feign调用其它接口报错

    问题描述 Spring Cloud Feign调用其它服务报错,错误提示如下:Failed to instantiate [java.util.List]: Specified class is an ...

  4. 笔记:Spring Cloud Feign Hystrix 配置

    在 Spring Cloud Feign 中,除了引入了用户客户端负载均衡的 Spring Cloud Ribbon 之外,还引入了服务保护与容错的工具 Hystrix,默认情况下,Spring Cl ...

  5. 笔记:Spring Cloud Feign 其他配置

    请求压缩 Spring Cloud Feign 支持对请求与响应进行GZIP压缩,以减少通信过程中的性能损耗,我们只需要通过下面二个参数设置,就能开启请求与响应的压缩功能,yml配置格式如下: fei ...

  6. 笔记:Spring Cloud Feign 声明式服务调用

    在实际开发中,对于服务依赖的调用可能不止一处,往往一个接口会被多处调用,所以我们通常会针对各个微服务自行封装一些客户端类来包装这些依赖服务的调用,Spring Cloud Feign 在此基础上做了进 ...

  7. 第六章:声明式服务调用:Spring Cloud Feign

    Spring Cloud Feign 是基于 Netflix Feign 实现的,整合了 Spring Cloud Ribbon 和 Spring Cloud Hystrix,除了提供这两者的强大功能 ...

  8. Spring Cloud feign

    Spring Cloud feign使用 前言 环境准备 应用模块 应用程序 应用启动 feign特性 综上 1. 前言 我们在前一篇文章中讲了一些我使用过的一些http的框架 服务间通信之Http框 ...

  9. RestTemplate OR Spring Cloud Feign 上传文件

    SpringBoot,通过RestTemplate 或者 Spring Cloud Feign,上传文件(支持多文件上传),服务端接口是MultipartFile接收. 将文件的字节流,放入ByteA ...

随机推荐

  1. 【luogu4781】拉格朗日插值

    题目背景 这是一道模板题 题目描述 由小学知识可知,nn个点(x_i,y_i)(xi​,yi​)可以唯一地确定一个多项式 现在,给定nn个点,请你确定这个多项式,并将kk代入求值 求出的值对99824 ...

  2. 想学习linux操作系统,于是选择了在win8 虚拟机VM player 里装了Linux版本Centos7

    第一次接触linux,第一次玩linux的命令行哈. 以下python使用的都是自带的python2.x版本 先新建一个简单的文件夹py_studydir 新建该文件夹下面的一个py文件 写入pyth ...

  3. Netfilter 之 iptable_nat

    初始化 iptable_nat_table_init函数通过调用ipt_register_table完成NAT表注册和钩子函数注册的功能:该流程与iptable_filter的函数调用的函数一致,此处 ...

  4. Ubuntu使用PBIS认证

    1:下载 https://github.com/BeyondTrust/pbis-open/releases wget https://github.com/BeyondTrust/pbis-open ...

  5. shell 拾遗

    1, 按照行读取文件 while read line do echo ${line} done < ${filename} 2.循环中使用命令输出 while read line do echo ...

  6. 提高组刷题班 DAY 1 上午

    低仿机器人(robo,1s,64M) 题解 大模拟 代码 #include <cstdio> #include <cstring> #include <iostream& ...

  7. SMARTY核心

    http://www.smarty.net/http://smarty.php.net/manual/en/ 1.配置 define("ROOTPATH",dirname(__FI ...

  8. Spring Security登录超时,angular ajax请求出错自动跳转至登录页(jQuery也适用)

    公司开发采用Spring Security+AngualerJS框架,在session过期之后,ajax请求会直接出错.本文介绍如何实现出错情况下自动跳转至登录页. 整体思路是,session过期后, ...

  9. [jquery]JSON.parse()与JSON.stringify()

    JSON.parse()[从一个字符串中解析出json对象] 例子: //定义一个字符串 var data='{"name":"goatling"}' //解析 ...

  10. *Scala API - 并发编程