package com.example.demo.storage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Service;
import org.springframework.util.FileSystemUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.stream.Stream;
@Service
public class FileSystemStorageService implements StorageService {
private final Path rootLocation;
@Autowired
public FileSystemStorageService(StorageProperties properties) {
this.rootLocation = Paths.get(properties.getLocation());
}
@Override
public void store(MultipartFile file) {
try {
if (file.isEmpty()) {
throw new StorageException("Failed to store empty file.");
}
Path destinationFile = this.rootLocation.resolve(
Paths.get(file.getOriginalFilename()))
.normalize().toAbsolutePath();
if (!destinationFile.getParent().equals(this.rootLocation.toAbsolutePath())) {
// This is a security check
throw new StorageException("Cannot store file outside current directory.");
}
try (InputStream inputStream = file.getInputStream()) {
Files.copy(inputStream, destinationFile,
StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
throw new StorageException("Failed to store file.", e);
}
}
@Override
public Stream<Path> loadAll() {
try {
return Files.walk(this.rootLocation, 1)
.filter(path -> !path.equals(this.rootLocation))
.map(this.rootLocation::relativize);
} catch (IOException e) {
throw new StorageException("Failed to read stored files", e);
}
}
@Override
public Path load(String filename) {
return rootLocation.resolve(filename);
}
@Override
public Resource loadAsResource(String filename) {
try {
Path file = load(filename);
Resource resource = new UrlResource(file.toUri());
if (resource.exists() || resource.isReadable()) {
return resource;
} else {
throw new StorageFileNotFoundException(
"Could not read file: " + filename);
}
} catch (MalformedURLException e) {
throw new StorageFileNotFoundException("Could not read file: " + filename, e);
}
}
@Override
public void deleteAll() {
FileSystemUtils.deleteRecursively(rootLocation.toFile());
}
@Override
public void init() {
try {
Files.createDirectories(rootLocation);
} catch (IOException e) {
throw new StorageException("Could not initialize storage", e);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java+SpringBoot的保险信息网站毕业设计(源码+说明+演示视频).zip
共443个文件
js:94个
jpg:69个
css:57个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 5 浏览量
2023-06-25
21:50:53
上传
评论
收藏 41.24MB ZIP 举报
温馨提示
基于Java+SpringBoot的保险信息网站毕业设计(源码+说明+演示视频).zip 【项目技术】 java+mysql+b/s+springboot 【实现功能】 分为了前端和后端。 管理员模块的主要功能需求包括了系统的维护、保险产品的管理,新闻资讯的管理等。 用户端功能可以浏览保险产品、观看当下与保险有关的最新资讯以及在线留言等。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java+SpringBoot的保险信息网站毕业设计(源码+说明+演示视频).zip (443个子文件)
.browserslistrc 33B
User.class 8KB
FileSystemStorageService.class 6KB
FileUploadController.class 5KB
Insurance.class 5KB
Recommend.class 5KB
Comment.class 4KB
News.class 4KB
UserRepository.class 2KB
RecommendRepository.class 2KB
ExposeEntityIdRestRepositoryRestConfigurer.class 1KB
InsuranceRepository.class 1KB
CommentRepository.class 1002B
DemoApplication.class 806B
StorageProperties.class 720B
StorageFileNotFoundException.class 667B
StorageException.class 616B
StorageService.class 580B
NewsRepository.class 528B
chunk-vendors.67018e50.css 228KB
chunk-vendors.67018e50.css 228KB
index.css 228KB
app.711dc16d.css 209KB
app.711dc16d.css 209KB
chunk-vendors.259bd0ec.css 204KB
chunk-vendors.259bd0ec.css 204KB
bootstrap.css 183KB
bootstrap.min.css 138KB
all.css 62KB
editor.9be2e4d6.css 37KB
editor.9be2e4d6.css 37KB
style.css 36KB
bootstrap-grid.css 34KB
bootstrap-grid.min.css 24KB
jquery.fancybox.min.css 14KB
bootstrap-reboot.css 5KB
icon.649ff013.css 5KB
icon.649ff013.css 5KB
upload.5df925fb.css 4KB
upload.5df925fb.css 4KB
bootstrap-reboot.min.css 4KB
home.cce0acf9.css 3KB
home.cce0acf9.css 3KB
main.css 3KB
app.f0308011.css 2KB
app.f0308011.css 2KB
markdown.360c635a.css 2KB
markdown.360c635a.css 2KB
dashboard.1dd31924.css 2KB
dashboard.1dd31924.css 2KB
owl.carousel.min.css 1KB
drag.0d86e883.css 1KB
drag.0d86e883.css 1KB
403.eaddfc90.css 724B
404.dc58a6fc.css 724B
403.eaddfc90.css 724B
404.dc58a6fc.css 724B
login.17c453b1.css 691B
login.17c453b1.css 691B
color-green.css 687B
color-dark.css 438B
table.3d7cc353.css 361B
table.3d7cc353.css 361B
chunk-7bb20528.6e71b5ee.css 335B
chunk-405a902d.9320ad64.css 335B
chunk-7bb20528.6e71b5ee.css 335B
chunk-405a902d.9320ad64.css 335B
chart.531d6ca1.css 231B
chart.531d6ca1.css 231B
permission.37db8fc8.css 162B
permission.37db8fc8.css 162B
i18n.8a49cc5f.css 115B
i18n.8a49cc5f.css 115B
icon.css 89B
tabs.acfac5ad.css 58B
tabs.acfac5ad.css 58B
fa-solid-900.70e65a7d.eot 176KB
fa-solid-900.eot 176KB
fa-solid-900.70e65a7d.eot 176KB
fa-brands-400.9b6c8da3.eot 116KB
fa-brands-400.eot 116KB
fa-brands-400.9b6c8da3.eot 116KB
fa-regular-400.7422060c.eot 40KB
fa-regular-400.eot 40KB
fa-regular-400.7422060c.eot 40KB
fontello.e73a0647.eot 15KB
fontello.e73a0647.eot 15KB
.gitignore 395B
.gitignore 238B
.gitignore 231B
.gitignore 0B
admin.html 3KB
admin.html 3KB
index.html 2KB
index.html 2KB
index.html 602B
index.html 593B
FileSystemStorageService.java 3KB
FileUploadController.java 2KB
User.java 1KB
共 443 条
- 1
- 2
- 3
- 4
- 5
资源评论
职场程序猿
- 粉丝: 2894
- 资源: 3683
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python中,要实现连接多个相机并识别多个二维码.rar
- 使用FFT算法对一个信号进行分析.rar
- 171cms游戏应用下载系统源码.zip
- 基于jsp+servlet+mysql蛋糕甜品店购物网站源码+数据库(期末大作业).zip
- Java项目:在线蛋糕商城系统(java+jsp+mysql)源码+数据库+期末大作业.zip
- ZapyaClient10_7-1.apk
- 织梦cms站长导航网站源码.zip
- 基于SSM+MySQL的网络投票调查问卷系统源码+数据库(java期末大作业).zip
- 基于jsp+servlet的宠物商城网站系统源码+数据库(java期末大作业).zip
- 基于Python+Tensorflow实现声纹识别+源代码+文档说明.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功