Springcloud feign调用之获取接口响应数据(io流)

    技术2022-07-11  114

     

    feign接口

    @RequestMapping(value = "v1.0/fileUpload/download",method =RequestMethod.GET,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) feign.Response download(@RequestParam("id") Long id); IdDTO<Long> idDTO = new IdDTO<>(); idDTO.setId(fileId); Response vo = fileServiceFeignV2.download(fileId); Response.Body body = vo.body(); log.info("headers=="+vo.headers().keySet()); log.info("body=="+body); log.info("status=="+vo.status()); String fileName=vo.headers().get("content-disposition").toString(); String docPath = "/data/hyzs/doc_instance/" + UUID.randomUUID() + "." + StringUtils.substringAfterLast(fileName, ".").replace("]",""); try {// InputStream inputStream=body.asInputStream(); FileUtil.getFile(inputStream,docPath); } catch (IOException e) { e.printStackTrace(); }

     

    Processed: 0.009, SQL: 9