From b8f53f6adce1c5a382820406fea95c71d987890c Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Thu, 20 Mar 2025 10:19:48 +0800 Subject: [PATCH] =?UTF-8?q?OA=E9=99=84=E4=BB=B6=E5=A4=A7=E5=B0=8F=E5=92=8C?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/java/shkd/utils/AttachmentFileUtil.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/java/shkd/utils/AttachmentFileUtil.java b/main/java/shkd/utils/AttachmentFileUtil.java index afb834e..44d066b 100644 --- a/main/java/shkd/utils/AttachmentFileUtil.java +++ b/main/java/shkd/utils/AttachmentFileUtil.java @@ -135,7 +135,7 @@ public class AttachmentFileUtil { TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache(); InputStream inputs; FileService service = FileServiceFactory.getAttachmentFileService(); - int filesize = 0; + byte[] filecontent; //遍历目标目录,得到所有文件 for (int i = 0; i < filenames.size(); i++) { destFile = filenames.getJSONObject(i); @@ -153,14 +153,14 @@ public class AttachmentFileUtil { // inputs = service.getInputStream("E:\\dobews\\dobe_cosmic6\\replay_pid13348.log"); // logger.info("文件大小"+inputs.available());//Linux服务器上此方法不能返回文件大小,都是0 //文件大小 - filesize = ByteStreams.toByteArray(inputs).length; - attachItem.put("size", filesize); - logger.info("文件大小"+filesize); - if(filesize == 0){ + filecontent = ByteStreams.toByteArray(inputs); + attachItem.put("size", filecontent.length); + logger.info("文件大小"+filecontent.length); + if(filecontent.length == 0){ attachItem.put("size", 60000); } //将文件流存入临时文件缓存(拷贝完成)(最后一个参数为缓存有效期,600秒) - tempUrl = cache.saveAsUrl(fileName, inputs, 600);//此方法执行后inputs会被自动关闭,后续不能再对inputs操作 + tempUrl = cache.saveAsUrl(fileName, filecontent, 600);//此方法执行后inputs会被自动关闭,后续不能再对inputs操作 //修改时间 attachItem.put("lastModified",System.currentTimeMillis());