I am trying to download some files vis sftp using a java application which uses the sshj library. I am using this tutorial
My code is as follows:
try {
sftpClient = client.newSFTPClient();
remoteFileList = sftpClient.ls("gtdt/xml");
logger.debug("trying to explicitly donwload file");
sftpClient.get("remotepath/xml/somefile.xml", new FileSystemFile(localDownloadDir));
} catch (IOException e) {
logger.error("Error getting list of remote files on sftp server", e);
fail("error getting list or remote ftp files");
}
Later I loop over the files that were returned:
assertTrue(remoteFileList.size() > 0);
for (RemoteResourceInfo info : remoteFileList) {
logger.info(info.toString());
}
but when I try to download any files (have tried one and many) like so
// get first file in list and download
RemoteResourceInfo info = remoteFileList.get(0);
try {
String localCopyPath = localDownloadDir.getAbsolutePath() + "/" + info.getName();
FileSystemFile localCopyFile = new FileSystemFile(localDownloadDir.getAbsolutePath() + "/" + info.getName());
logger.debug("attempting to copy remote file " + info.getPath() + " to : " + localCopyPath);
sftpClient.get("remotepath/xml/somefile.xml", localCopyFile);
} catch (IOException e) {
logger.error("unable to copy file to local dir ", e);
fail("unable to copy " + info.getName() + " to local dir " + localDownloadDir.getAbsolutePath());
}
I get an error like this:
[main] WARN net.schmizz.sshj.xfer.FileSystemFile - Could not set permissions for c:\mypath\somefile.xml to 1a0
any idea how to fix this? The actual code that is being executed there starts at line 142 here. It wasn't clear to me if this is and issue on my local machine or something I need to configure in sshj.
thanks!