|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package me.zhengjie.modules.uploadnew.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.hutool.system.OsInfo;
|
|
|
|
|
import cn.hutool.system.SystemUtil;
|
|
|
|
@ -13,6 +12,7 @@ import java.io.File;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author wjt
|
|
|
|
|
* @date 2021/8/6
|
|
|
|
@ -41,26 +41,26 @@ public class BuildPathUtils {
|
|
|
|
|
/**
|
|
|
|
|
* 构建文件上传保存路径
|
|
|
|
|
*/
|
|
|
|
|
public String buildFilePath(String fileName) {
|
|
|
|
|
public String buildFilePath() {
|
|
|
|
|
// 获取环境配置信息
|
|
|
|
|
OsInfo osInfo = SystemUtil.getOsInfo();
|
|
|
|
|
// 定义的时间格式
|
|
|
|
|
String timeFormate = DateUtil.today();
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
String timeForMate = LocalDateTime.now().format(dtf) + RandomUtil.randomString(4);
|
|
|
|
|
String dirPath;
|
|
|
|
|
if (osInfo.isWindows()) {
|
|
|
|
|
dirPath = fileBasePathWindows + timeFormate + File.separator + fileName;
|
|
|
|
|
dirPath = fileBasePathWindows + timeForMate;
|
|
|
|
|
FileUtil.mkdir(new File(dirPath));
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
|
} else if (osInfo.isLinux()) {
|
|
|
|
|
dirPath = fileBasePathLinux + timeFormate + File.separator + fileName;
|
|
|
|
|
dirPath = fileBasePathLinux + timeForMate;
|
|
|
|
|
FileUtil.mkdir(new File(dirPath));
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
|
} else if (osInfo.isMac()) {
|
|
|
|
|
|
|
|
|
|
dirPath = fileBasePathMac + timeFormate + File.separator + fileName;
|
|
|
|
|
dirPath = fileBasePathMac + timeForMate;
|
|
|
|
|
FileUtil.mkdir(new File(dirPath));
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
@ -74,13 +74,13 @@ public class BuildPathUtils {
|
|
|
|
|
*/
|
|
|
|
|
public String buildFileOosPath(String subFixFile) {
|
|
|
|
|
// 加一个音频格式不存在的格式通配
|
|
|
|
|
if (StringUtils.isBlank(subFixFile)){
|
|
|
|
|
if (StringUtils.isBlank(subFixFile)) {
|
|
|
|
|
subFixFile = "wav";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OsInfo osInfo = SystemUtil.getOsInfo();
|
|
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
|
|
String timeFormate = LocalDateTime.now().format(dtf) + RandomUtil.randomString(10) + "." + subFixFile;
|
|
|
|
|
String timeFormate = LocalDateTime.now().format(dtf) + RandomUtil.randomString(10) + "." + subFixFile;
|
|
|
|
|
|
|
|
|
|
String dirPath;
|
|
|
|
|
if (osInfo.isWindows()) {
|
|
|
|
@ -89,12 +89,12 @@ public class BuildPathUtils {
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
|
} else if (osInfo.isLinux()) {
|
|
|
|
|
dirPath = timeFormate;
|
|
|
|
|
dirPath = timeFormate;
|
|
|
|
|
FileUtil.mkdir(new File(dirPath));
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
|
} else if (osInfo.isMac()) {
|
|
|
|
|
dirPath = timeFormate;
|
|
|
|
|
dirPath = timeFormate;
|
|
|
|
|
FileUtil.mkdir(new File(dirPath));
|
|
|
|
|
// 构建存储文件
|
|
|
|
|
return dirPath;
|
|
|
|
|