|
@@ -13,7 +13,10 @@ import sys.sc.opplugin.utils.SftpClient;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -89,20 +92,37 @@ public class CreatDatPlugin extends AbstractListPlugin {
|
|
|
String username=jkdataDy.getString("nckd_user");
|
|
|
|
|
|
String password=jkdataDy.getString("nckd_password");
|
|
|
-
|
|
|
|
|
|
int port=jkdataDy.getInt("nckd_port");
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
}
|