杜洪波
7 天以前 9925bc571e1234d96a66063134ab9a9ddfd7c031
src/main/java/com/product/file/service/FileManagerService.java
@@ -1024,13 +1024,22 @@
               ftpService.downloadFile(path, os);
            }
         } else {
                InputStream is = null;
                try {
                    Object fileContent = attachmentFse.getValue("file_content");
                    boolean saveInDb = fileContent != null;
                    if (saveInDb) {
                        // 存储到数据库
                        is = (InputStream) fileContent;
                    } else {
            // 直接在本地的目录中找文件
            String localBasePath = Global.getSystemConfig("local.dir", "");
            path = localBasePath + File.separator + path;
            File file = new File(path);
                        is = Files.newInputStream(file.toPath());
                    }
            int len;
            byte[] b = new byte[1024];
            try (InputStream is = new FileInputStream(file)) {
               while ((len = is.read(b)) > 0) {
                  if (Global.getPropertyToBoolean("file.encrypt", "true")) {
                     // 需要解密
@@ -1040,6 +1049,12 @@
                     os.write(b, 0, len);
                  }
               }
            } catch (Exception e) {
                    throw new BaseException(FileCode.GET_FILE_BYTES_FAIL);
                } finally {
                    if (is != null) {
                        is.close();
                    }
            }
         }