use of com.fo0.robot.model.FileTransferData 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