|
@@ -13,7 +13,10 @@ import sys.sc.opplugin.utils.SftpClient;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.nio.file.Path;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -89,20 +92,37 @@ public class CreatDatPlugin extends AbstractListPlugin {
|
|
String username=jkdataDy.getString("nckd_user");
|
|
String username=jkdataDy.getString("nckd_user");
|
|
//服务器密码
|
|
//服务器密码
|
|
String password=jkdataDy.getString("nckd_password");
|
|
String password=jkdataDy.getString("nckd_password");
|
|
-
|
|
|
|
//服务器端口号
|
|
//服务器端口号
|
|
int port=jkdataDy.getInt("nckd_port");
|
|
int port=jkdataDy.getInt("nckd_port");
|
|
-// SftpClient sftpClient=new SftpClient(host,username,password,port);
|
|
|
|
-// //获取服务器连接
|
|
|
|
-// try {
|
|
|
|
-// sftpClient.connect();
|
|
|
|
-// //上传文件到服务器指定路径
|
|
|
|
-// sftpClient.fileCreat(filePath,nckd_url+filename);
|
|
|
|
-// //关闭连接
|
|
|
|
-// sftpClient.disconnect();
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// throw new RuntimeException(e);
|
|
|
|
-// }
|
|
|
|
|
|
+ SftpClient sftpClient=new SftpClient(host,username,password,port);
|
|
|
|
+ //获取服务器连接
|
|
|
|
+ try {
|
|
|
|
+ sftpClient.connect();
|
|
|
|
+ //上传文件到服务器指定路径
|
|
|
|
+ sftpClient.fileCreat(filePath,nckd_url+filename);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ //关闭连接
|
|
|
|
+ sftpClient.disconnect();
|
|
|
|
+ }
|
|
|
|
+ if (name.equals("uploadfile"))
|
|
|
|
+ {
|
|
|
|
+ String remoteFilePath="/home/kingdee/cosmic/nginx-appstatic/store/appstatic/";
|
|
|
|
+ SftpClient sftpClient=new SftpClient("192.168.10.69","root","Kd@86262007",22);
|
|
|
|
+ try {
|
|
|
|
+ sftpClient.connect();
|
|
|
|
+ // 创建一个新的远程文件并写入内容
|
|
|
|
+ Path localFile = Files.createTempFile("tempfile", ".txt");
|
|
|
|
+ Files.write(localFile, Collections.singleton("Hello, SFTP!"));
|
|
|
|
+ sftpClient.fileCreat(localFile.toString(),remoteFilePath); // 清理临时文件
|
|
|
|
+ Files.delete(localFile);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ sftpClient.disconnect();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|