Package org.apache.sshd.sftp.client.impl
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 interface
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]
protected Buffer
private final Buffer[]
protected final int
private final AbstractSftpClient
protected SftpClient.CloseableHandle
private final byte[]
private SftpMessage
protected final org.slf4j.Logger
private int
protected long
private final boolean
private final int
private final String
protected final Deque
<SftpAckData> private final int
private 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 void
checkStatus
(AbstractSftpClient client, Buffer buf) void
close()
void
flush()
private Buffer
final AbstractSftpClient
final String
getPath()
The remotely accessed file pathprivate void
private long
internalTransfer
(SftpOutputStreamAsync.ByteInput stream, boolean forceFlush) boolean
isOpen()
void
setOffset
(long offset) toString()
long
transferFrom
(InputStream stream) long
transferFrom
(ReadableByteChannel stream, long count) void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.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
-AbstractSftpClient
to 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.OpenMode
s 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
-AbstractSftpClient
to 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.CloseableHandle
of 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
-AbstractSftpClient
to 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.CloseableHandle
of the remote file to write tocloseHandle
- whether to close thehandle
when this output stream is closed
-
-
Method Details
-
getClient
- Specified by:
getClient
in interfaceSftpClientHolder
-
setOffset
public void setOffset(long offset) -
getPath
The remotely accessed file path- Returns:
- Remote file path
-
isOpen
public boolean isOpen() -
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in 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:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
internalFlush
- Throws:
IOException
-
checkStatus
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
toString
-