From 85bc2484c98f4eb0bfb2bad003c9702bdf3cbe13 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 27 五月 2020 00:05:24 +0800
Subject: [PATCH] 优化代码

---
 java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java b/java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java
index 0fe7bde..9ffee77 100644
--- a/java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java
+++ b/java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java
@@ -2,6 +2,7 @@
 
 import com.java110.utils.util.Base64Convert;
 import com.java110.utils.util.DateUtil;
+import com.tencentcloudapi.tci.v20190318.models.FaceExpressionResult;
 import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPFile;
@@ -209,6 +210,14 @@
         return return_arraybyte;
     }
 
+    public static void main(String[] args) {
+        FtpUploadTemplate ftpUploadTemplate = new FtpUploadTemplate();
+        String img = ftpUploadTemplate.download("/hc/img/20200518/","ed05abae-2eca-40ff-81a8-b586ff2e6a36.jpg",
+                "118.89.243.11",617,"hcdemo","45j74jpWTf7bNhnC");
+
+        System.out.printf("img="+img);
+    }
+
     public String download(String remotePath, String fileName, String server, int port, String userName, String userPassword) {
         InputStream is = null;
         ByteArrayOutputStream bos = null;
@@ -219,6 +228,7 @@
             }
             ftpClient.login(userName, userPassword);
             ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+            ftpClient.enterLocalPassiveMode();
             int reply = ftpClient.getReplyCode();
             if (!FTPReply.isPositiveCompletion(reply)) {
                 ftpClient.disconnect();
@@ -226,8 +236,7 @@
             String f = new String(
                     (remotePath + fileName).getBytes("GBK"),
                     FTP.DEFAULT_CONTROL_ENCODING);
-            ftpClient.changeWorkingDirectory(remotePath);
-            is = ftpClient.retrieveFileStream(fileName);// 鑾峰彇杩滅▼ftp涓婃寚瀹氭枃浠剁殑InputStream
+            is = ftpClient.retrieveFileStream(f);// 鑾峰彇杩滅▼ftp涓婃寚瀹氭枃浠剁殑InputStream
             if (null == is) {
                 throw new FileNotFoundException(remotePath);
             }

--
Gitblit v1.8.0