From 9925bc571e1234d96a66063134ab9a9ddfd7c031 Mon Sep 17 00:00:00 2001
From: 杜洪波 <1074825718@qq.com>
Date: 星期一, 03 十一月 2025 15:53:06 +0800
Subject: [PATCH] Merge branch 'dev' of http://nonxin.cn:8090/r/product/product-server-file/V2.0.0 into dev

---
 src/main/java/com/product/file/service/FileManagerService.java |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/product/file/service/FileManagerService.java b/src/main/java/com/product/file/service/FileManagerService.java
index db4ae7e..373343b 100644
--- a/src/main/java/com/product/file/service/FileManagerService.java
+++ b/src/main/java/com/product/file/service/FileManagerService.java
@@ -1024,13 +1024,22 @@
 					ftpService.downloadFile(path, os);
 				}
 			} else {
-				// 鐩存帴鍦ㄦ湰鍦扮殑鐩綍涓壘鏂囦欢
-				String localBasePath = Global.getSystemConfig("local.dir", "");
-				path = localBasePath + File.separator + path;
-				File file = new File(path);
-				int len;
-				byte[] b = new byte[1024];
-				try (InputStream is = new FileInputStream(file)) {
+                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];
 					while ((len = is.read(b)) > 0) {
 						if (Global.getPropertyToBoolean("file.encrypt", "true")) {
 							// 闇�瑕佽В瀵�
@@ -1040,7 +1049,13 @@
 							os.write(b, 0, len);
 						}
 					}
-				}
+				} catch (Exception e) {
+                    throw new BaseException(FileCode.GET_FILE_BYTES_FAIL);
+                } finally {
+                    if (is != null) {
+                        is.close();
+                    }
+                }
 			}
 
 			return os.toByteArray();

--
Gitblit v1.9.2