From 5519e6a190a714923eabc3156539a48b572f3fa5 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 06 六月 2024 18:17:01 +0800
Subject: [PATCH] 代码初始化

---
 server/system_service/src/main/java/com/doumee/core/utils/FtpUtil.java |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/server/system_service/src/main/java/com/doumee/core/utils/FtpUtil.java b/server/system_service/src/main/java/com/doumee/core/utils/FtpUtil.java
index a62bf46..5a6fbd5 100644
--- a/server/system_service/src/main/java/com/doumee/core/utils/FtpUtil.java
+++ b/server/system_service/src/main/java/com/doumee/core/utils/FtpUtil.java
@@ -15,6 +15,7 @@
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
+import org.apache.xpath.operations.Bool;
 import sun.misc.BASE64Encoder;
 
 /** */
@@ -237,7 +238,6 @@
 		// 璁剧疆PassiveMode浼犺緭
 		try {
 			ftpClient.enterLocalPassiveMode();
-
 			// 璁剧疆浠ヤ簩杩涘埗娴佺殑鏂瑰紡浼犺緭
 			ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
 			ftpClient.setControlEncoding("GBK");
@@ -266,6 +266,42 @@
 		}
 		return false;
 	}
+
+	public boolean uploadInputstreamBatch(InputStream inputStream, String remote, Boolean close)  {
+		// 璁剧疆PassiveMode浼犺緭
+		try {
+			ftpClient.enterLocalPassiveMode();
+			// 璁剧疆浠ヤ簩杩涘埗娴佺殑鏂瑰紡浼犺緭
+			ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+			ftpClient.setControlEncoding("GBK");
+			// 瀵硅繙绋嬬洰褰曠殑澶勭悊
+			String remoteFileName = remote;
+			if (remote.contains("/")) {
+				remoteFileName = remote.substring(remote.lastIndexOf("/") + 1);
+				// 鍒涘缓鏈嶅姟鍣ㄨ繙绋嬬洰褰曠粨鏋勶紝鍒涘缓澶辫触鐩存帴杩斿洖
+				if (StringUtils.equals(CreateDirecroty(remote, ftpClient), "2")) {
+					log.error("鍒涘缓ftp鐩綍澶辫触======================="+remote);
+					return false;
+				}
+			}
+			boolean result = ftpClient.storeFile(remoteFileName, inputStream);
+			inputStream.close();
+			if(close){
+				ftpClient.logout();
+			}
+			if(result){
+				log.info("涓婁紶鏂囦欢鎴愬姛======================"+remote);
+			}else{
+				log.error("涓婁紶鏂囦欢澶辫触======================="+remote);
+			}
+			return result;
+		}catch (Exception e){
+			e.printStackTrace();
+			log.error("涓婁紶鏂囦欢澶辫触======================="+remote);
+		}
+		return false;
+	}
+
 	public int getNumFromStr(String str,char searchstr) {
 		int count = 0;
 		char[] charArray = str.toCharArray();

--
Gitblit v1.9.3