use of net.schmizz.sshj.xfer.scp.SCPFileTransfer in project asterixdb by apache.
the class RemoteCopyFileAction method doPerform.
@Override
protected void doPerform() throws Exception {
client.loadKnownHosts();
try {
client.connect(hostname, port);
client.authPublickey(username, keyLocation);
SCPFileTransfer scpft = client.newSCPFileTransfer();
scpft.upload(srcFilePath, destFilePath);
} finally {
client.close();
}
}
use of net.schmizz.sshj.xfer.scp.SCPFileTransfer in project Robot by fo0.
the class SCPClient method upload.
public FileTransferData upload(String remotePath, String localPath) {
if (client == null) {
return null;
}
FileTransferData data = FileTransferData.builder().build();
data.setLocalPath(localPath);
data.setRemotePath(remotePath);
data.setStarted(System.currentTimeMillis());
SCPFileTransfer dlClient = client.newSCPFileTransfer();
try {
dlClient.upload(localPath, remotePath);
data.setSuccess(true);
data.setSize(FileUtils.sizeOf(new File(localPath)));
} catch (Exception e) {
Logger.error("failed to upload file " + e);
} finally {
data.setFinished(System.currentTimeMillis());
}
return data;
}
use of net.schmizz.sshj.xfer.scp.SCPFileTransfer in project Robot by fo0.
the class SCPClient method download.
public FileTransferData download(String localPath, String remotePath) {
if (client == null) {
return null;
}
FileTransferData data = FileTransferData.builder().build();
data.setLocalPath(localPath);
data.setRemotePath(remotePath);
data.setStarted(System.currentTimeMillis());
SCPFileTransfer dlClient = client.newSCPFileTransfer();
try {
dlClient.download(remotePath, localPath);
data.setSuccess(true);
data.setSize(FileUtils.sizeOf(new File(localPath)));
} catch (Exception e) {
Logger.error("failed to download file " + e);
} finally {
data.setFinished(System.currentTimeMillis());
}
return data;
}
Aggregations