|
@@ -98,9 +98,7 @@ public class FileUploadUtils
|
|
|
* @throws InvalidExtensionException 文件校验异常
|
|
|
*/
|
|
|
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
|
|
|
- throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
|
|
- InvalidExtensionException
|
|
|
- {
|
|
|
+ throws Exception {
|
|
|
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
|
|
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
|
|
{
|
|
@@ -139,13 +137,24 @@ public class FileUploadUtils
|
|
|
return desc;
|
|
|
}
|
|
|
|
|
|
- public static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
|
|
+ public static final String getPathFileName(String uploadDir, String fileName) throws Exception
|
|
|
{
|
|
|
- int dirLastIndex = com.citygis.common.config.CitygisConfig.getProfile().length() + 1;
|
|
|
+ int dirLastIndex = getSystemType().length() + 1;
|
|
|
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
|
|
return "/" + currentDir + "/" + fileName;
|
|
|
}
|
|
|
|
|
|
+ public static String getSystemType() throws Exception {
|
|
|
+ String osName = System.getProperty("os.name").toLowerCase();
|
|
|
+ if (osName.contains("win")) {
|
|
|
+ return com.citygis.common.config.CitygisConfig.getWindows_profile();
|
|
|
+ } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("mac")) {
|
|
|
+ return com.citygis.common.config.CitygisConfig.getLinux_profile();
|
|
|
+ } else {
|
|
|
+ return "unknown";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 文件大小校验
|
|
|
*
|