public PacketReader(SFTPEngine engine) { this.engine = engine; log = engine.getLoggerFactory().getLogger(getClass()); this.in = engine.getSubsystem().getInputStream(); setName("sftp reader"); }
@Before public void setUp() throws Exception { PipedOutputStream pipedout = new PipedOutputStream(); PipedInputStream pipedin = new PipedInputStream(pipedout); dataout = new DataOutputStream(pipedout); SFTPEngine engine = Mockito.mock(SFTPEngine.class); Subsystem subsystem = Mockito.mock(Subsystem.class); Mockito.when(engine.getLoggerFactory()).thenReturn(LoggerFactory.DEFAULT); Mockito.when(engine.getSubsystem()).thenReturn(subsystem); Mockito.when(subsystem.getInputStream()).thenReturn(pipedin); reader = new PacketReader(engine); }
rfos = rf.new RemoteFileOutputStream(0, 16); new StreamCopier(fis, rfos, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getRemoteMaxPacketSize() - rf.getOutgoingPacketOverhead()) .keepFlushing(false) .listener(listener)
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }
public PacketReader(SFTPEngine engine) { this.engine = engine; this.in = engine.getSubsystem().getInputStream(); setName("sftp reader"); }
public PacketReader(SFTPEngine engine) { this.engine = engine; log = engine.getLoggerFactory().getLogger(getClass()); this.in = engine.getSubsystem().getInputStream(); setName("sftp reader"); }
private String uploadFile(final StreamCopier.Listener listener, final LocalSourceFile local, final String remote) throws IOException { final String adjusted = prepareFile(local, remote); final RemoteFile rf = engine.open(adjusted, EnumSet.of(OpenMode.WRITE, OpenMode.CREAT, OpenMode.TRUNC)); try { final InputStream fis = local.getInputStream(); final RemoteFile.RemoteFileOutputStream rfos = rf.new RemoteFileOutputStream(0, 16); try { new StreamCopier(fis, rfos) .bufSize(engine.getSubsystem().getRemoteMaxPacketSize() - rf.getOutgoingPacketOverhead()) .keepFlushing(false) .listener(listener) .copy(); } finally { fis.close(); rfos.close(); } } finally { rf.close(); } return adjusted; }
rfos = rf.new RemoteFileOutputStream(0, 16); new StreamCopier(fis, rfos, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getRemoteMaxPacketSize() - rf.getOutgoingPacketOverhead()) .keepFlushing(false) .listener(listener)
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }
private LocalDestFile downloadFile(final StreamCopier.Listener listener, final RemoteResourceInfo remote, final LocalDestFile local) throws IOException { final LocalDestFile adjusted = local.getTargetFile(remote.getName()); final RemoteFile rf = engine.open(remote.getPath()); try { final RemoteFile.ReadAheadRemoteFileInputStream rfis = rf.new ReadAheadRemoteFileInputStream(16); final OutputStream os = adjusted.getOutputStream(); try { new StreamCopier(rfis, os, engine.getLoggerFactory()) .bufSize(engine.getSubsystem().getLocalMaxPacketSize()) .keepFlushing(false) .listener(listener) .copy(); } finally { rfis.close(); os.close(); } } finally { rf.close(); } return adjusted; }