|
@ -1,5 +1,6 @@ |
|
|
package com.inscloudtech.common.utils.file; |
|
|
package com.inscloudtech.common.utils.file; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
import com.inscloudtech.common.constant.Constants; |
|
|
import com.inscloudtech.common.constant.Constants; |
|
|
import com.inscloudtech.common.exception.file.FileNameLengthLimitExceededException; |
|
|
import com.inscloudtech.common.exception.file.FileNameLengthLimitExceededException; |
|
@ -107,7 +108,7 @@ public class FileUploadUtils { |
|
|
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); |
|
|
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
assertAllowed(file, allowedExtension); |
|
|
|
|
|
|
|
|
// assertAllowed(file, allowedExtension); |
|
|
|
|
|
|
|
|
String fileName = extractFilename(file); |
|
|
String fileName = extractFilename(file); |
|
|
|
|
|
|
|
@ -235,7 +236,10 @@ public class FileUploadUtils { |
|
|
String[] allowedExtension = MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION; |
|
|
String[] allowedExtension = MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION; |
|
|
String fileName = file.getOriginalFilename(); |
|
|
String fileName = file.getOriginalFilename(); |
|
|
String extension = getExtension(file); |
|
|
String extension = getExtension(file); |
|
|
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { |
|
|
|
|
|
|
|
|
if(StrUtil.isEmpty(extension)){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
/* if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { |
|
|
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { |
|
|
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { |
|
|
return false; |
|
|
return false; |
|
|
// throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, |
|
|
// throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, |
|
@ -256,7 +260,7 @@ public class FileUploadUtils { |
|
|
// throw new InvalidExtensionException(allowedExtension, extension, fileName); |
|
|
// throw new InvalidExtensionException(allowedExtension, extension, fileName); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|