From 19f0eca493f7e17ab7b67d28cf77d80de364576c Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 28 十月 2024 15:00:57 +0800
Subject: [PATCH] ll
---
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..8712f61 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 , Integer index ) {
+ // 璁剧疆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 (Constants.equalsInteger(index,Constants.ONE) && 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