【发布时间】:2021-11-01 22:08:36
【问题描述】:
我有一个使用 JSch 通过 SSH 从服务器获取的文件的 InputStream。我想在我的 Spring Boot 应用程序中将它作为文件返回。
尝试使用我在许多论坛上阅读的 ResponseEntity,但它不起作用
【问题讨论】:
-
你也可以这样使用:File file = new File("file.txt"); FileUtils.copyInputStreamToFile(inputStream, file); response.setContentType("应用程序/强制下载"); response.setHeader("Content-Disposition", "attachment;filename=" + "file.txt"); return new HttpEntity
(new FileSystemResource(file));
标签: java spring-boot ssh inputstream jsch