新增临时文件存放地址配置,支持相对路径

This commit is contained in:
WIN-VSNMD38DUOC\Administrator
2024-04-28 17:42:15 +08:00
parent 5f3e17f0cf
commit e2d5ad6d1a
4 changed files with 17 additions and 6 deletions

View File

@@ -125,13 +125,9 @@ public class DownloadAction {
public Map<String, Object> packZip(String filenames) throws Exception{ public Map<String, Object> packZip(String filenames) throws Exception{
try { try {
PathUtils.directory(FmtConfig.Upload_File_Path); PathUtils.directory(FmtConfig.Upload_File_Path);
//临时文件目录 PathUtils.directory(FmtConfig.Temp_File_Path);
String temp = "temp";
String zipPath = FmtConfig.Upload_File_Path + File.separator + temp;
File zipFile = new File(zipPath);
if (!zipFile.exists()) zipFile.mkdirs();
String zipName = String.valueOf(System.currentTimeMillis()); String zipName = String.valueOf(System.currentTimeMillis());
String zipDir = zipPath + File.separator + zipName + ".zip"; String zipDir = FmtConfig.Temp_File_Path + File.separator + zipName + ".zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipDir)); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipDir));
File folder = new File(FmtConfig.Upload_File_Path); File folder = new File(FmtConfig.Upload_File_Path);
File[] listOfFiles = folder.listFiles(); File[] listOfFiles = folder.listFiles();

View File

@@ -15,6 +15,8 @@ public class FmtConfig {
public static String Upload_File_Path = "./data/files"; public static String Upload_File_Path = "./data/files";
public static String Temp_File_Path = "./data/files/temp";
@Value("${somkit.upload.path}") @Value("${somkit.upload.path}")
public void setUpload_File_Path(String upload_file_path) { public void setUpload_File_Path(String upload_file_path) {
if(StringUtils.hasText(upload_file_path)){ if(StringUtils.hasText(upload_file_path)){
@@ -25,4 +27,15 @@ public class FmtConfig {
Upload_File_Path = upload_file_path; Upload_File_Path = upload_file_path;
} }
} }
@Value("${somkit.upload.temp-path}")
public void setTemp_File_Path(String temp_file_path) {
if(StringUtils.hasText(temp_file_path)){
//如果使用相对路径,转换为绝对路径
if(temp_file_path.startsWith("./")){
temp_file_path = PathUtils.resolve(temp_file_path);
}
Temp_File_Path = temp_file_path;
}
}
} }

View File

@@ -19,6 +19,7 @@ spring:
somkit: somkit:
upload: upload:
path: ./data/files #上传文件路径 可以使用绝对路径,也可使用相对路径 path: ./data/files #上传文件路径 可以使用绝对路径,也可使用相对路径
temp-path: ./data/files/temp #临时文件存放地址 可以使用绝对路径,也可使用相对路径
cache: cache:
rocks-db: rocks-db:
path: ./cache/rocksdb # RocksDB缓存路径 可以使用绝对路径,也可使用相对路径 path: ./cache/rocksdb # RocksDB缓存路径 可以使用绝对路径,也可使用相对路径

View File

@@ -21,4 +21,5 @@
``` ```
修改RocksDB文件目录配置使其支持使用相对路径 修改RocksDB文件目录配置使其支持使用相对路径
修改上传文件目录配置,使其支持使用相对路径 修改上传文件目录配置,使其支持使用相对路径
新增临时文件存放地址配置,支持相对路径
``` ```