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());