public SFTPClient(SFTPEngine engine) { this.engine = engine; log = engine.getLoggerFactory().getLogger(getClass()); this.xfer = new SFTPFileTransfer(engine); }
@Override public void download(String source, LocalDestFile dest) throws IOException { final PathComponents pathComponents = engine.getPathHelper().getComponents(source); final FileAttributes attributes = engine.stat(source); new Downloader().download(getTransferListener(), new RemoteResourceInfo(pathComponents, attributes), dest); }
private void setAttributes(LocalSourceFile local, String remotePath) throws IOException { if (getPreserveAttributes()) { engine.setAttributes(remotePath, getAttributes(local)); } }
@Override public void upload(LocalSourceFile localFile, String remotePath) throws IOException { new Uploader(localFile, remotePath).upload(getTransferListener()); }
public void get(String source, String dest) throws IOException { xfer.download(source, dest); }
public void put(String source, String dest) throws IOException { xfer.upload(source, dest); }
private String uploadDir(final TransferListener listener, final LocalSourceFile local, final String remote) throws IOException { makeDirIfNotExists(remote); for (LocalSourceFile f : local.getChildren(getUploadFilter())) upload(listener, f, engine.getPathHelper().adjustForParent(remote, f.getName())); return remote; }
private LocalDestFile downloadDir(final TransferListener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetDirectory(remote.getName()); final RemoteDirectory rd = engine.openDir(remote.getPath()); try { for (RemoteResourceInfo rri : rd.scan(getDownloadFilter())) download(listener, rri, adjusted.getChild(rri.getName())); } finally { rd.close(); } return adjusted; }
@Override public void upload(LocalSourceFile localFile, String remotePath) throws IOException { new Uploader().upload(getTransferListener(), localFile, remotePath); }
public void get(String source, LocalDestFile dest) throws IOException { xfer.download(source, dest); }
public void put(LocalSourceFile source, String dest) throws IOException { xfer.upload(source, dest); }
private String uploadDir(final TransferListener listener, final LocalSourceFile local, final String remote) throws IOException { final String adjusted = prepareDir(local, remote); for (LocalSourceFile f : local.getChildren(getUploadFilter())) upload(listener, f, adjusted); return adjusted; }
private LocalDestFile downloadDir(final TransferListener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetDirectory(remote.getName()); final RemoteDirectory rd = engine.openDir(remote.getPath()); try { for (RemoteResourceInfo rri : rd.scan(getDownloadFilter())) download(listener, rri, adjusted.getChild(rri.getName())); } finally { rd.close(); } return adjusted; }
@Override public void download(String source, LocalDestFile dest) throws IOException { final PathComponents pathComponents = engine.getPathHelper().getComponents(source); final FileAttributes attributes = engine.stat(source); new Downloader().download(getTransferListener(), new RemoteResourceInfo(pathComponents, attributes), dest); }
@Override public void upload(LocalSourceFile localFile, String remotePath) throws IOException { new Uploader(localFile, remotePath).upload(getTransferListener()); }
@Override public void download(String source, String dest) throws IOException { download(source, new FileSystemFile(dest)); }
@Override public void upload(String source, String dest) throws IOException { upload(new FileSystemFile(source), dest); }
@SuppressWarnings("PMD.MissingBreakInSwitch") private void download(final TransferListener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjustedFile; switch (remote.getAttributes().getType()) { case DIRECTORY: adjustedFile = downloadDir(listener.directory(remote.getName()), remote, local); break; case UNKNOWN: log.warn("Server did not supply information about the type of file at `{}` " + "-- assuming it is a regular file!", remote.getPath()); case REGULAR: adjustedFile = downloadFile(listener.file(remote.getName(), remote.getAttributes().getSize()), remote, local); break; default: throw new IOException(remote + " is not a regular file or directory"); } if (getPreserveAttributes()) copyAttributes(remote, adjustedFile); }
public SFTPClient(SFTPEngine engine) { this.engine = engine; this.xfer = new SFTPFileTransfer(engine); }
private String uploadDir(final TransferListener listener, final LocalSourceFile local, final String remote) throws IOException { makeDirIfNotExists(remote); for (LocalSourceFile f : local.getChildren(getUploadFilter())) upload(listener, f, engine.getPathHelper().adjustForParent(remote, f.getName())); return remote; }