From ad7d4d8927f6596967cd3cca7664eb596061e90c Mon Sep 17 00:00:00 2001 From: wkeyuan Date: Fri, 28 Apr 2023 15:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=B1=BB=E5=9E=8B=E8=BF=87=E6=BB=A4=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/baidu/ueditor/upload/StorageManager.java | 1 - .../diaowen/common/plugs/file/FileMagicUtils.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/baidu/ueditor/upload/StorageManager.java b/src/main/java/com/baidu/ueditor/upload/StorageManager.java index bbbc571..8f2fd62 100755 --- a/src/main/java/com/baidu/ueditor/upload/StorageManager.java +++ b/src/main/java/com/baidu/ueditor/upload/StorageManager.java @@ -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); diff --git a/src/main/java/net/diaowen/common/plugs/file/FileMagicUtils.java b/src/main/java/net/diaowen/common/plugs/file/FileMagicUtils.java index 3a31fac..785ec51 100644 --- a/src/main/java/net/diaowen/common/plugs/file/FileMagicUtils.java +++ b/src/main/java/net/diaowen/common/plugs/file/FileMagicUtils.java @@ -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验测