今天就跟大家聊聊有關(guān)如何進(jìn)行SpringCloudFeign接口返回流的實(shí)現(xiàn),可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站建設(shè)、做網(wǎng)站、烏魯木齊網(wǎng)絡(luò)推廣、小程序開發(fā)、烏魯木齊網(wǎng)絡(luò)營銷、烏魯木齊企業(yè)策劃、烏魯木齊品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)建站為所有大學(xué)生創(chuàng)業(yè)者提供烏魯木齊建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com
服務(wù)提供者
@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);
服務(wù)消費(fèi)者
@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) { } }
看完上述內(nèi)容,你們對如何進(jìn)行SpringCloudFeign接口返回流的實(shí)現(xiàn)有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。