fix: 公共文件处理调整
Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
f6c4c989cc
commit
7eb6322a7e
|
@ -348,11 +348,14 @@ public class FileUtils {
|
|||
}
|
||||
|
||||
public static void deleteFile(String path) {
|
||||
if (StringUtils.isNotBlank(path)) {
|
||||
validateFileName(path);
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDir(String path) {
|
||||
File file = new File(path);
|
||||
|
|
|
@ -161,9 +161,9 @@ public class CommandService {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean checkKeyStore(String password, String path) {
|
||||
public void checkKeyStore(String password, String path) {
|
||||
try {
|
||||
String keytoolArgs[] = {"keytool", "-rfc", "-list", "-keystore", path, "-storepass", password};
|
||||
String[] keytoolArgs = {"keytool", "-rfc", "-list", "-keystore", path, "-storepass", password};
|
||||
Process p = new ProcessBuilder(keytoolArgs).start();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
|
||||
String line = null;
|
||||
|
@ -176,11 +176,9 @@ public class CommandService {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public class FileUtil {
|
|||
*/
|
||||
public static File multipartFileToFile(MultipartFile file) {
|
||||
if (file != null && file.getSize() > 0) {
|
||||
try (InputStream ins = file.getInputStream();) {
|
||||
try (InputStream ins = file.getInputStream()) {
|
||||
FileUtils.validateFileName(file.getOriginalFilename());
|
||||
File toFile = new File(file.getOriginalFilename());
|
||||
inputStreamToFile(ins, toFile);
|
||||
return toFile;
|
||||
|
@ -49,6 +50,7 @@ public class FileUtil {
|
|||
|
||||
/**
|
||||
* File 转 MultipartFile
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
|
@ -59,7 +61,7 @@ public class FileUtil {
|
|||
OutputStream os = item.getOutputStream();
|
||||
os.write(FileUtils.fileToByte(file));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(e);
|
||||
}
|
||||
return new CommonsMultipartFile(item);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue