1、新增文档分类管理
2、新增资源管理开发
This commit is contained in:
@@ -5,6 +5,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.rzdata.common.listener.PutObjectProgressListener;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -280,4 +282,50 @@ public class FileUploadUtils
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成合并后的文件路径
|
||||
*
|
||||
* @param baseDir 文件存储根目录
|
||||
* @param fileName 上传的文件名
|
||||
* @return 合并后文件的完整路径
|
||||
*/
|
||||
public static String generateMergedFilePath(String baseDir, String fileName) {
|
||||
// 获取当前日期路径
|
||||
String datePath = DateUtil.today().replace("-", "/");
|
||||
|
||||
// 获取文件的基本名称和扩展名
|
||||
String baseName = StrUtil.subBefore(fileName, ".", true);
|
||||
String extension = StrUtil.subAfter(fileName, ".", true);
|
||||
|
||||
// 生成唯一文件名,使用时间戳
|
||||
String uniqueFileName = baseName + "_" + System.currentTimeMillis() + "." + extension;
|
||||
|
||||
// 合并文件路径: baseDir/yyyy/MM/dd/uploadId/uniqueFileName
|
||||
String mergedFilePath = Paths.get(baseDir, datePath, uniqueFileName).toString();
|
||||
|
||||
return mergedFilePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件名称
|
||||
*
|
||||
* @param baseDir 文件存储根目录
|
||||
* @param fileNames 上传的文件名
|
||||
* @return 合并后文件的完整路径
|
||||
*/
|
||||
public static String getFilePath(String baseDir, String fileNames) {
|
||||
String extension = StrUtil.subAfter(fileNames, ".", true);
|
||||
|
||||
String fileName = StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||
FilenameUtils.getBaseName(fileNames), Seq.getId(Seq.uploadSeqType), extension);;
|
||||
|
||||
try {
|
||||
return getPathFileName(baseDir, fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user