人工交互文件上传文件夹路径拼接修改

This commit is contained in:
qiaoqinzheng 2024-03-07 08:51:15 +08:00
parent 0a00916d19
commit 05b6e83608

View File

@ -62,8 +62,11 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
FileOutputStream fos = null;
ZipInputStream zipInputStream = null;
String slash = SymbolConstant.SINGLE_SLASH;
String filePath = spectrumPathProperties.getUploadPath() + slash + username;
//ftp父级路径
String rootPath = ftpUtil.getFtpRootPath();
//上传文件夹路径
String filePath = rootPath + spectrumPathProperties.getUploadPath() + slash + username;
//本地临时文件夹路径
String tempFilePath = System.getProperty("java.io.tmpdir") + username + slash;
List<String> fileNames = new ArrayList<>();
List<File> fileList = new ArrayList<>();
@ -98,7 +101,6 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
// 上传所有文件
List<String> failList = new ArrayList<>();
String rootPath = ftpUtil.getFtpRootPath();
for (File oneFile : fileList) {
String fileName = oneFile.getName();
// 判断能谱文件名称是否符合规则不符合则进行重命名
@ -107,7 +109,7 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time));
fileName = nameStandUtil.GetFileNameFromDateTime(struct.measurement_id, suffix);
}
String fullFilePath = rootPath + filePath + slash + fileName;
String fullFilePath = filePath + slash + fileName;
FileInputStream local = new FileInputStream(oneFile);
boolean success = ftpClient.storeFile(fullFilePath, local);
if (!success) failList.add(fullFilePath);