From 29e51c9f05c6ea12695b3001822232fc84d279bc Mon Sep 17 00:00:00 2001 From: philip <244793088@qq.com> Date: Thu, 16 Sep 2021 15:25:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9B=BE=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foreverwin/mesnac/common/controller/FileController.java | 2 +- .../java/com/foreverwin/mesnac/common/ftp/CappFtpClient.java | 2 +- .../mesnac/common/service/impl/FileServiceImpl.java | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java index dc107291..880c34f5 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java @@ -70,7 +70,7 @@ public class FileController { //服务器发布 String coderPath = new String(path.getBytes("ISO8859_1")); String newPath = new String(coderPath.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING); - in = ftpClient.getFtp(newPath); + in = ftpClient.getFtp(path); if(null == in){ in = ftpClient.getFtp(new String(coderPath.getBytes("UTF-8"), FTPClient.DEFAULT_CONTROL_ENCODING)); } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/ftp/CappFtpClient.java b/common/src/main/java/com/foreverwin/mesnac/common/ftp/CappFtpClient.java index 9418f852..8fdef290 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/ftp/CappFtpClient.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/ftp/CappFtpClient.java @@ -311,7 +311,7 @@ public class CappFtpClient { * @throws Exception */ public InputStream getFtp(String path) throws Exception { - connect(); + login(); InputStream in = ftp.retrieveFileStream(path); return in; } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java index 329b248d..22946e0f 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/FileServiceImpl.java @@ -12,7 +12,6 @@ import com.foreverwin.modular.core.util.CommonMethods; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.IOException; @@ -21,8 +20,6 @@ import java.util.Map; @Service public class FileServiceImpl implements FileService { - @Value("${cappftp.server}") - private String address; @Autowired private SfcService sfcService; @Autowired @@ -47,7 +44,7 @@ public class FileServiceImpl implements FileService { for (int i = 0; i < files.length; i++) { if(files[i].isFile()){ String filename=files[i].getName(); - pathMap.put(filename,address+path+filename); + pathMap.put(filename,path+filename); } } } From ad947ed227dcbf3001d6ae108da6011f2f1bba0e Mon Sep 17 00:00:00 2001 From: philip <244793088@qq.com> Date: Thu, 16 Sep 2021 15:41:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=9B=BE=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foreverwin/mesnac/common/controller/FileController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java index 880c34f5..03d1761e 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/FileController.java @@ -68,11 +68,11 @@ public class FileController { String path = request.getParameter("Path"); try { //服务器发布 - String coderPath = new String(path.getBytes("ISO8859_1")); - String newPath = new String(coderPath.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING); + //String coderPath = new String(path.getBytes("ISO8859_1")); + //String newPath = new String(coderPath.getBytes("GBK"), FTPClient.DEFAULT_CONTROL_ENCODING); in = ftpClient.getFtp(path); if(null == in){ - in = ftpClient.getFtp(new String(coderPath.getBytes("UTF-8"), FTPClient.DEFAULT_CONTROL_ENCODING)); + in = ftpClient.getFtp(new String(path.getBytes("UTF-8"), FTPClient.DEFAULT_CONTROL_ENCODING)); } //本地测试