|
@@ -41,16 +41,18 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
String suffix = FileUtil.getSuffix(fileName);
|
|
String suffix = FileUtil.getSuffix(fileName);
|
|
|
|
|
|
- String path = getFilePath();
|
|
|
|
|
|
+ String rootPath = BladeApplication.isLocalDev() ? "D:/hx/" : "/mnt/file/";
|
|
|
|
+ String path = DateUtil.format(new Date(), "yyyy-MM/dd/");
|
|
String filePath = path + UUID.randomUUID() + "." + suffix;
|
|
String filePath = path + UUID.randomUUID() + "." + suffix;
|
|
|
|
|
|
- FileUtil.mkdir(path);
|
|
|
|
|
|
+ FileUtil.mkdir(rootPath + path);
|
|
|
|
+
|
|
FileOutputStream fileOutputStream = null;
|
|
FileOutputStream fileOutputStream = null;
|
|
InputStream inputStream = null;
|
|
InputStream inputStream = null;
|
|
|
|
|
|
try {
|
|
try {
|
|
inputStream = file.getInputStream();
|
|
inputStream = file.getInputStream();
|
|
- fileOutputStream = new FileOutputStream(filePath);
|
|
|
|
|
|
+ fileOutputStream = new FileOutputStream(rootPath + filePath);
|
|
int index;
|
|
int index;
|
|
byte[] bytes = new byte[1024];
|
|
byte[] bytes = new byte[1024];
|
|
|
|
|
|
@@ -158,16 +160,4 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
return list.stream().map(item -> BeanUtil.toBean(item, FileInfoParam.class)).collect(Collectors.toList());
|
|
return list.stream().map(item -> BeanUtil.toBean(item, FileInfoParam.class)).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取文件保存路径
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private String getFilePath() {
|
|
|
|
- StringJoiner joiner = new StringJoiner("/");
|
|
|
|
- joiner.add(BladeApplication.isLocalDev() ? "D:/hx" : "/mnt/file");
|
|
|
|
- joiner.add(DateUtil.format(new Date(), "yyyy-MM/dd/"));
|
|
|
|
- return joiner.toString();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|