mirror of
https://gitee.com/wkeyuan/DWSurvey.git
synced 2024-12-01 19:49:01 +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,
|
public static State saveFileByInputStream(InputStream is, String path,
|
||||||
long maxSize) {
|
long maxSize) {
|
||||||
System.out.println("saveFileByInputStream");
|
|
||||||
BaseState validateState = isUserUpFileType(is,path.substring(path.lastIndexOf(".")));
|
BaseState validateState = isUserUpFileType(is,path.substring(path.lastIndexOf(".")));
|
||||||
if(!validateState.isSuccess()) return validateState;
|
if(!validateState.isSuccess()) return validateState;
|
||||||
State state = new BaseState(false, AppInfo.IO_ERROR);
|
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 {
|
public static FileMagic getFileMagic(File inp, String fileSuffix) throws Exception {
|
||||||
FileInputStream fis = new FileInputStream(inp);
|
FileMagic fileMagic = null;
|
||||||
return getFileMagic(fis,fileSuffix);
|
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验测
|
//切换到使用最新的tika验测
|
||||||
|
Loading…
Reference in New Issue
Block a user