|
|
@ -28,7 +28,7 @@ public class FileUploadUtils { |
|
|
|
/** |
|
|
|
* 默认的文件名最大长度 100 |
|
|
|
*/ |
|
|
|
public static final int DEFAULT_FILE_NAME_LENGTH = 100; |
|
|
|
public static final int DEFAULT_FILE_NAME_LENGTH = 255; |
|
|
|
|
|
|
|
/** |
|
|
|
* 默认上传的地址 |
|
|
@ -95,26 +95,26 @@ public class FileUploadUtils { |
|
|
|
|
|
|
|
String fileName = file.getOriginalFilename(); |
|
|
|
|
|
|
|
String localSubPath = DateUtils.datePath() + File.separator + fileName; |
|
|
|
String localSubPath = DateUtils.datePath() + "/" + fileName; |
|
|
|
|
|
|
|
File targetFile = new File(baseDir + File.separator + localSubPath); |
|
|
|
File targetFile = new File(baseDir + "/" + localSubPath); |
|
|
|
|
|
|
|
if (!targetFile.getParentFile().exists()) { |
|
|
|
targetFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
if (targetFile.exists()) { |
|
|
|
localSubPath = DateUtils.datePath() + File.separator + IdUtils.fastUUID() + File.separator + fileName; |
|
|
|
targetFile = new File(baseDir + File.separator + localSubPath); |
|
|
|
localSubPath = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "/" + fileName; |
|
|
|
targetFile = new File(baseDir + "/" + localSubPath); |
|
|
|
if (!targetFile.getParentFile().exists()) { |
|
|
|
targetFile.getParentFile().mkdirs(); |
|
|
|
} |
|
|
|
} |
|
|
|
targetFile.createNewFile(); |
|
|
|
file.transferTo(targetFile); |
|
|
|
if (Constants.RESOURCE_PREFIX.endsWith(File.separator)) { |
|
|
|
File currFile = new File(new File(baseDir).getAbsolutePath()+"/" + localSubPath); |
|
|
|
file.transferTo(currFile); |
|
|
|
if (Constants.RESOURCE_PREFIX.endsWith("/")) { |
|
|
|
return Constants.RESOURCE_PREFIX + localSubPath; |
|
|
|
} else { |
|
|
|
return Constants.RESOURCE_PREFIX + File.separator + localSubPath; |
|
|
|
return Constants.RESOURCE_PREFIX + "/" + localSubPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|