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