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

 

feign接口

   @RequestMapping(value = "v1.0/fileUpload/download",method =RequestMethod.GET,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    feign.Response download(@RequestParam("id") Long id);
 IdDTO 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();
        }

 

你可能感兴趣的:(java)