From 886af3196e50294645d55dfaceadf90d2cee73da Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 16 May 2022 11:03:26 +0800
Subject: [PATCH] ftp path 路径修改,去除中文字符处理
---
src/main/java/org/springblade/modules/FTP/Monitor.java | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/springblade/modules/FTP/Monitor.java b/src/main/java/org/springblade/modules/FTP/Monitor.java
index de4764e..a5affee 100644
--- a/src/main/java/org/springblade/modules/FTP/Monitor.java
+++ b/src/main/java/org/springblade/modules/FTP/Monitor.java
@@ -12,6 +12,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.SocketException;
+import java.net.URLEncoder;
import java.util.List;
import static org.springblade.common.config.FtpConfig.*;
@@ -23,6 +24,8 @@
*/
@Component
public class Monitor {
+
+
/**
* 读取文件(用户对象)单用户新增
@@ -52,8 +55,9 @@
// 设置编码格式
ftp.setControlEncoding("GBK");
+ System.out.println("ftpPathIn = " + ftpPathIn);
// 检验文件是否存在
- boolean ftpFile = ftp.changeWorkingDirectory(ftpPath);
+ boolean ftpFile = ftp.changeWorkingDirectory(ftpPathIn);
System.out.println("检验文件是否存在 = " + ftpFile);
FTPFile[] files = ftp.listFiles();
System.out.println("files = " + files);
@@ -72,14 +76,14 @@
if (substring1.equals("n")){
System.out.println("-------接收到内网回传的文件: " + substring1);
//把文件下载到本地
- FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
+ FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
// 解析数据
String s = OutJson.TestJson(fileName);
//数据处理
Result result = DataHandler.handler(s,uuid);
//删除本地文件
MysqlCenlint.deletess(fileName);
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
is.close();
ftp.completePendingCommand();
if (result.getCode()==200) {
@@ -147,7 +151,7 @@
ftp.setControlEncoding("GBK");
// 检验文件是否存在
- ftp.changeWorkingDirectory(ftpPath);
+ ftp.changeWorkingDirectory(ftpPathIn);
FTPFile[] files = ftp.listFiles();
if (files.length==0){
return new Result(400,null,"未读取到文件",null);
@@ -158,7 +162,7 @@
String substring1 = fileName.substring(0, 2);
if (substring1.equals("nl")){
//把文件下载到本地
- FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
+ FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
// 解析数据
String s = OutJson.TestJson(fileName);
//数据处理
@@ -168,7 +172,7 @@
//删除本地文件
MysqlCenlint.deletess(fileName);
//删除 ftp 文件
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
//返回
return result;
}
@@ -222,7 +226,7 @@
ftp.setControlEncoding("GBK");
// 检验文件是否存在
- ftp.changeWorkingDirectory(ftpPath);
+ ftp.changeWorkingDirectory(ftpPathIn);
FTPFile[] files = ftp.listFiles();
if (files.length==0){
return new Result(400,null,"未读取到文件",null);
@@ -233,7 +237,7 @@
String substring1 = fileName.substring(0, 2);
if (substring1.equals("nt")){
//把文件下载到本地
- FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
+ FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
// 解析数据
String s = OutJson.TestJson(fileName);
//数据处理
@@ -243,7 +247,7 @@
//删除本地文件
MysqlCenlint.deletess(fileName);
//删除 ftp 文件
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
//返回
return result;
}
@@ -295,7 +299,7 @@
ftp.setControlEncoding("GBK");
// 检验文件是否存在
- ftp.changeWorkingDirectory(ftpPath);
+ ftp.changeWorkingDirectory(ftpPathIn);
FTPFile[] files = ftp.listFiles();
if (files.length==0){
return false;
@@ -310,7 +314,7 @@
String substring1 = fileName.substring(0, 4);
if (substring1.equals("nsql")) {
//把文件下载到本地
- FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
+ FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
//
String s = OutJson.TestJson(fileName);
//sql语句
@@ -336,7 +340,7 @@
//删除本地服务器文件
MysqlCenlint.deletess(fileName);
//删除 ftp 服务器文件
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
}
//关闭流
is.close();
@@ -389,7 +393,7 @@
ftp.setControlEncoding("GBK");
// 检验文件是否存在
- ftp.changeWorkingDirectory(ftpPath);
+ ftp.changeWorkingDirectory(ftpPathIn);
FTPFile[] files = ftp.listFiles();
if (files.length==0){
return new Result(400,null,"未读取到文件",null);
@@ -400,7 +404,7 @@
String substring1 = fileName.substring(0, 2);
if (substring1.equals("ns")){
//把文件下载到本地
- FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPath, localPath, fileName);
+ FtpUtil.downloadFtpFile(ftpHost, ftpUserNameIn, ftpPasswordIn, ftpPort, ftpPathIn, localPath, fileName);
// 解析数据
String s = OutJson.TestJson(fileName);
//数据处理
@@ -410,7 +414,7 @@
//删除本地文件
MysqlCenlint.deletess(fileName);
//删除 ftp 文件
- FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName);
+ FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPathIn, fileName);
//返回
return result;
}
--
Gitblit v1.9.3