【fix sonar】FileTypeFilter文件
This commit is contained in:
+5
-4
@@ -1,5 +1,6 @@
|
||||
package com.jero.common.util.filter;
|
||||
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -96,11 +97,11 @@ public class FileTypeFilter {
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
public static void fileTypeFilter(MultipartFile file) throws Exception {
|
||||
public static void fileTypeFilter(MultipartFile file){
|
||||
String suffix = getFileType(file);
|
||||
for (String type : forbidType) {
|
||||
if (type.contains(suffix)) {
|
||||
throw new Exception("上传失败,文件类型异常:" + suffix);
|
||||
throw new JeroBootException("上传失败,文件类型异常:" + suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public class FileTypeFilter {
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
private static String getFileType(MultipartFile file) throws Exception {
|
||||
private static String getFileType(MultipartFile file) throws JeroBootException {
|
||||
String fileExtendName = null;
|
||||
InputStream is;
|
||||
try {
|
||||
@@ -139,7 +140,7 @@ public class FileTypeFilter {
|
||||
is.close();
|
||||
return fileExtendName;
|
||||
} catch (Exception exception) {
|
||||
throw new Exception(exception.getMessage(), exception);
|
||||
throw new JeroBootException(exception.getMessage(), exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user