|
@@ -6,6 +6,8 @@ import at.acdp.urweb.URBot;
|
|
|
import at.acdp.urweb.rt.GetRobotRealtimeData;
|
|
|
import at.acdp.urweb.sclient.URLog;
|
|
|
import com.eclipsesource.json.JsonArray;
|
|
|
+import net.schmizz.sshj.SSHClient;
|
|
|
+import net.schmizz.sshj.xfer.FileSystemFile;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import static spark.Spark.*;
|
|
@@ -80,5 +82,23 @@ public class WebServer {
|
|
|
}
|
|
|
return "[{}]";
|
|
|
});
|
|
|
+ get("/files/:path", (req, res) -> {
|
|
|
+ String path=req.params("from");
|
|
|
+ SSHClient ssh = new SSHClient();
|
|
|
+ // ssh.useCompression(); // Can lead to significant speedup (needs JZlib in classpath)
|
|
|
+ ssh.loadKnownHosts();
|
|
|
+ ssh.connect(params.robotIP, params.robotPort);
|
|
|
+ try {
|
|
|
+ ssh.authPublickey(System.getProperty(params.sshUsername));
|
|
|
+ ssh.newSCPFileTransfer().download(path, new FileSystemFile("C:\\tmp\\"));
|
|
|
+
|
|
|
+ }catch (Exception e) {
|
|
|
+ logger.warn("",e);
|
|
|
+
|
|
|
+ } finally{
|
|
|
+ ssh.disconnect();
|
|
|
+ }
|
|
|
+ return "[{}]";
|
|
|
+ });
|
|
|
}
|
|
|
}
|