|
|
@ -178,21 +178,23 @@ public class LocalFileUtil implements IFileUtil{
|
|
|
|
|
|
|
|
|
|
|
|
public String uploadByRelativePath(MultipartFile file, String relativePath,String caseName) {
|
|
|
|
public String uploadByRelativePath(MultipartFile file, String relativePath,String caseName) {
|
|
|
|
Assert.isTrue(!file.isEmpty(), "文件不存在");
|
|
|
|
Assert.isTrue(!file.isEmpty(), "文件不存在");
|
|
|
|
|
|
|
|
System.out.println("文件不存在!");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 创建目录如果不存在
|
|
|
|
// 创建目录如果不存在
|
|
|
|
File directory = new File(relativePath);
|
|
|
|
File directory = new File(relativePath);
|
|
|
|
if (!directory.exists()) {
|
|
|
|
if (!directory.exists()) {
|
|
|
|
directory.mkdirs();
|
|
|
|
directory.mkdirs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("1");
|
|
|
|
// 设置目标文件路径
|
|
|
|
// 设置目标文件路径
|
|
|
|
String result = caseName == null ? file.getOriginalFilename() : caseName;
|
|
|
|
String result = caseName == null ? file.getOriginalFilename() : caseName;
|
|
|
|
|
|
|
|
System.out.println("2");
|
|
|
|
int i = file.getOriginalFilename().lastIndexOf(".");
|
|
|
|
int i = file.getOriginalFilename().lastIndexOf(".");
|
|
|
|
|
|
|
|
System.out.println("3");
|
|
|
|
String substring = file.getOriginalFilename().substring(i);
|
|
|
|
String substring = file.getOriginalFilename().substring(i);
|
|
|
|
|
|
|
|
System.out.println("4");
|
|
|
|
File destFile = new File(relativePath + File.separator + result+substring);
|
|
|
|
File destFile = new File(relativePath + File.separator + result+substring);
|
|
|
|
|
|
|
|
System.out.println("5");
|
|
|
|
file.transferTo(destFile);
|
|
|
|
file.transferTo(destFile);
|
|
|
|
return "上传成功!";
|
|
|
|
return "上传成功!";
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|