mirror of
https://gitee.com/wkeyuan/DWSurvey.git
synced 2024-11-29 18:49:26 +08:00
优化上传文件类型过滤的方法
This commit is contained in:
parent
e9f328b936
commit
ad7d4d8927
@ -48,7 +48,6 @@ public class StorageManager {
|
||||
|
||||
public static State saveFileByInputStream(InputStream is, String path,
|
||||
long maxSize) {
|
||||
System.out.println("saveFileByInputStream");
|
||||
BaseState validateState = isUserUpFileType(is,path.substring(path.lastIndexOf(".")));
|
||||
if(!validateState.isSuccess()) return validateState;
|
||||
State state = new BaseState(false, AppInfo.IO_ERROR);
|
||||
|
@ -26,8 +26,17 @@ public class FileMagicUtils {
|
||||
|
||||
//根据文件获取对应的文件类型
|
||||
public static FileMagic getFileMagic(File inp, String fileSuffix) throws Exception {
|
||||
FileInputStream fis = new FileInputStream(inp);
|
||||
return getFileMagic(fis,fileSuffix);
|
||||
FileMagic fileMagic = null;
|
||||
FileInputStream fis = null;
|
||||
try{
|
||||
fis = new FileInputStream(inp);
|
||||
fileMagic = getFileMagic(fis,fileSuffix);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if (fis!=null) fis.close();
|
||||
}
|
||||
return fileMagic;
|
||||
}
|
||||
|
||||
//切换到使用最新的tika验测
|
||||
|
Loading…
Reference in New Issue
Block a user