Class SftpOutputStreamAsync
java.lang.Object
java.io.OutputStream
org.apache.sshd.common.util.io.output.OutputStreamWithChannel
org.apache.sshd.sftp.client.impl.SftpOutputStreamAsync
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Channel, SftpClientHolder
Implements an output stream for a given remote file
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected Bufferprivate final Buffer[]protected final intprivate final AbstractSftpClientprotected SftpClient.CloseableHandleprivate final byte[]private SftpMessageprotected final org.slf4j.Loggerprivate intprotected longprivate final booleanprivate final intprivate final Stringprotected final Deque<SftpAckData> private final intprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, Collection<SftpClient.OpenMode> mode) Creates a new stream to write data to a remote file.SftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, SftpClient.CloseableHandle handle) Creates a new stream to write data to a remote file.SftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, SftpClient.CloseableHandle handle, boolean closeHandle) Creates a new stream to write data to a remote file. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckStatus(AbstractSftpClient client, Buffer buf) voidclose()voidflush()private Bufferfinal AbstractSftpClientfinal StringgetPath()The remotely accessed file pathprivate voidprivate longinternalTransfer(SftpOutputStreamAsync.ByteInput stream, boolean forceFlush) booleanisOpen()voidsetOffset(long offset) toString()longtransferFrom(InputStream stream) longtransferFrom(ReadableByteChannel stream, long count) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class OutputStream
write
-
Field Details
-
log
protected final org.slf4j.Logger log -
bb
protected final byte[] bb -
bufferSize
protected final int bufferSize -
buffer
-
handle
-
offset
protected long offset -
pendingAcks
-
clientInstance
-
path
-
handleId
private final byte[] handleId -
ownsHandle
private final boolean ownsHandle -
bufferPool
-
packetSize
private final int packetSize -
sftpPreamble
private final int sftpPreamble -
usePacket
private final boolean usePacket -
nextBuffer
private int nextBuffer -
lastMsg
-
-
Constructor Details
-
SftpOutputStreamAsync
public SftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, Collection<SftpClient.OpenMode> mode) throws IOException Creates a new stream to write data to a remote file.- Parameters:
client-AbstractSftpClientto use for writing databufferSize- SFTP packet length to use. Most servers have a limit of 256kB. If zero, the stream picks a size such that each SFTP packet fits into a single SSH packet, i.e., roughly 32kB.path- remote path to write tomode-SftpClient.OpenModes for opening the file.- Throws:
IOException- if the remote file cannot be opened
-
SftpOutputStreamAsync
public SftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, SftpClient.CloseableHandle handle) Creates a new stream to write data to a remote file.- Parameters:
client-AbstractSftpClientto use for writing databufferSize- SFTP packet length to use. Most servers have a limit of 256kB. If zero, the stream picks a size such that each SFTP packet fits into a single SSH packet, i.e., roughly 32kB.handle-SftpClient.CloseableHandleof the remote file to write to; will be closed when this output stream is closed
-
SftpOutputStreamAsync
public SftpOutputStreamAsync(AbstractSftpClient client, int bufferSize, String path, SftpClient.CloseableHandle handle, boolean closeHandle) Creates a new stream to write data to a remote file.- Parameters:
client-AbstractSftpClientto use for writing databufferSize- SFTP packet length to use. Most servers have a limit of 256kB. If zero, the stream picks a size such that each SFTP packet fits into a single SSH packet, i.e., roughly 32kB.handle-SftpClient.CloseableHandleof the remote file to write tocloseHandle- whether to close thehandlewhen this output stream is closed
-
-
Method Details
-
getClient
- Specified by:
getClientin interfaceSftpClientHolder
-
setOffset
public void setOffset(long offset) -
getPath
-
isOpen
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
transferFrom
- Throws:
IOException
-
transferFrom
- Throws:
IOException
-
getBuffer
-
internalTransfer
private long internalTransfer(SftpOutputStreamAsync.ByteInput stream, boolean forceFlush) throws IOException - Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
internalFlush
- Throws:
IOException
-
checkStatus
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
toString
-