【发布时间】:2020-09-17 22:35:24
【问题描述】:
我正在使用 thymeleaf 开发一个 Spring Boot 项目,我需要创建一个文件并在上面放置一些行,然后将其发送给用户下载。
@PostMapping("/filegenerator")
public String createFile(@ModelAttribute("page") Page page, Model model) {
List<String> lines = new ArrayList<String>();
//Some code ..........
lines.forEach(l->{
System.out.println(l);
});
//Here I need to create a file with the List of lines
//And also put some code to download it
return "filegenerator";
}
【问题讨论】:
-
请分享更多信息。这个文件是什么(文本文件?图片?pdf?)?它只能由这个单个用户下载吗?是否有任何时间限制,在此之后文件不再可下载(也许在 1 小时后保留此文件只会浪费磁盘空间?)?您是在某个云中运行您的应用程序还是对对象存储桶具有其他类型的访问权限?
-
感谢您的评论。文件的类型是 sql 脚本(.sql),是的,只有该用户可以下载,他将填写表格并提交,他将获得文件下载。只是本地和即时我不需要云或存储
标签: java spring-boot thymeleaf eclipse-jee