删除部分本地文件操作的无用代码
This commit is contained in:
@@ -170,10 +170,8 @@ public class DownLoadController {
|
|||||||
try {
|
try {
|
||||||
FtpOperationUtil ftpUtil = new FtpOperationUtil();
|
FtpOperationUtil ftpUtil = new FtpOperationUtil();
|
||||||
|
|
||||||
long fileLength = new File(downLoadPath).length();
|
|
||||||
response.setContentType("application/x-msdownload;");
|
response.setContentType("application/x-msdownload;");
|
||||||
response.setHeader("Content-disposition", "attachment; filename=" + new String(tbFile.getColfilename().getBytes("utf-8"), "ISO8859-1"));
|
response.setHeader("Content-disposition", "attachment; filename=" + new String(tbFile.getColfilename().getBytes("utf-8"), "ISO8859-1"));
|
||||||
response.setHeader("Content-Length", String.valueOf(fileLength));
|
|
||||||
|
|
||||||
ftpUtil.connectServer();
|
ftpUtil.connectServer();
|
||||||
List<String> list = ftpUtil.getFileList("/");
|
List<String> list = ftpUtil.getFileList("/");
|
||||||
@@ -352,7 +350,8 @@ public class DownLoadController {
|
|||||||
RemoteExecuteCommandUtil rec = new RemoteExecuteCommandUtil(
|
RemoteExecuteCommandUtil rec = new RemoteExecuteCommandUtil(
|
||||||
remoteExecuteProperties.getIp(),
|
remoteExecuteProperties.getIp(),
|
||||||
remoteExecuteProperties.getUser(),
|
remoteExecuteProperties.getUser(),
|
||||||
remoteExecuteProperties.getPassword());
|
remoteExecuteProperties.getPassword(),
|
||||||
|
remoteExecuteProperties.getPort());
|
||||||
rec.login();
|
rec.login();
|
||||||
//登录FTP
|
//登录FTP
|
||||||
FtpOperationUtil ftpOperationUtil = new FtpOperationUtil();
|
FtpOperationUtil ftpOperationUtil = new FtpOperationUtil();
|
||||||
@@ -372,7 +371,6 @@ public class DownLoadController {
|
|||||||
|
|
||||||
response.setContentType("application/x-msdownload;");
|
response.setContentType("application/x-msdownload;");
|
||||||
response.setHeader("Content-disposition", "attachment; filename=" + new String(zipFileName.getBytes("utf-8"), "ISO8859-1"));
|
response.setHeader("Content-disposition", "attachment; filename=" + new String(zipFileName.getBytes("utf-8"), "ISO8859-1"));
|
||||||
|
|
||||||
InputStream inputStream = ftpOperationUtil.downFile("/zip/",zipFileName);
|
InputStream inputStream = ftpOperationUtil.downFile("/zip/",zipFileName);
|
||||||
System.out.println("【available】" + inputStream.available());
|
System.out.println("【available】" + inputStream.available());
|
||||||
//将打包好的文件输出到客户端
|
//将打包好的文件输出到客户端
|
||||||
|
|||||||
@@ -269,14 +269,6 @@ public class UpLoadController {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetFile.exists()) {
|
|
||||||
try {
|
|
||||||
targetFile.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Data
|
@Data
|
||||||
public class FtpProperties {
|
public class FtpProperties {
|
||||||
//服务器地址名称
|
//服务器地址名称
|
||||||
private String server = "192.168.79.138";
|
private String server = "176.122.138.235";
|
||||||
//端口号
|
//端口号
|
||||||
private int port = 21;
|
private int port = 21;
|
||||||
//用户名称
|
//用户名称
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ public class RemoteExecuteProperties {
|
|||||||
private String user;
|
private String user;
|
||||||
private String password;
|
private String password;
|
||||||
private String path;
|
private String path;
|
||||||
|
private int port;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ public class FtpOperationUtil {
|
|||||||
public String[] list(String path) throws IOException {
|
public String[] list(String path) throws IOException {
|
||||||
String[] dirs = path.split("/");
|
String[] dirs = path.split("/");
|
||||||
ftpClient.changeWorkingDirectory("/");
|
ftpClient.changeWorkingDirectory("/");
|
||||||
|
ftpClient.enterLocalPassiveMode();
|
||||||
for (int i = 1; dirs != null && i < dirs.length; i++) {
|
for (int i = 1; dirs != null && i < dirs.length; i++) {
|
||||||
dirs[i] = new String(dirs[i].getBytes("UTF-8"), "iso-8859-1");
|
dirs[i] = new String(dirs[i].getBytes("UTF-8"), "iso-8859-1");
|
||||||
ftpClient.changeWorkingDirectory(dirs[i]);
|
ftpClient.changeWorkingDirectory(dirs[i]);
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ public class RemoteExecuteCommandUtil {
|
|||||||
private String ip;
|
private String ip;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String userPwd;
|
private String userPwd;
|
||||||
|
private int port;
|
||||||
|
|
||||||
public RemoteExecuteCommandUtil(String ip, String userName, String userPwd) {
|
public RemoteExecuteCommandUtil(String ip, String userName, String userPwd,int port) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.userPwd = userPwd;
|
this.userPwd = userPwd;
|
||||||
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ public class RemoteExecuteCommandUtil {
|
|||||||
public Boolean login(){
|
public Boolean login(){
|
||||||
boolean flg=false;
|
boolean flg=false;
|
||||||
try {
|
try {
|
||||||
conn = new Connection(ip);
|
conn = new Connection(ip,port);
|
||||||
conn.connect();//连接
|
conn.connect();//连接
|
||||||
flg=conn.authenticateWithPassword(userName, userPwd);//认证
|
flg=conn.authenticateWithPassword(userName, userPwd);//认证
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ serverproperties:
|
|||||||
port_num: 8080
|
port_num: 8080
|
||||||
filePath: F:\JAVA Workspace\Temp\
|
filePath: F:\JAVA Workspace\Temp\
|
||||||
remoteproperties:
|
remoteproperties:
|
||||||
ip: 192.168.79.138
|
ip: 176.122.138.235
|
||||||
|
port: 26460
|
||||||
user: root
|
user: root
|
||||||
password: 27894869
|
password: B171b0GsMCD8
|
||||||
path: /home/ftp/cms/
|
path: /home/ftp/cms/
|
||||||
spring:
|
spring:
|
||||||
thymeleaf:
|
thymeleaf:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
public class RemoteExecuteCommandUtilTest {
|
public class RemoteExecuteCommandUtilTest {
|
||||||
|
|
||||||
RemoteExecuteCommandUtil rec=new RemoteExecuteCommandUtil("192.168.79.138", "root","27894869");
|
RemoteExecuteCommandUtil rec=new RemoteExecuteCommandUtil("176.122.138.235", "root","B171b0GsMCD8",26460);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void login() {
|
public void login() {
|
||||||
|
|||||||
Reference in New Issue
Block a user