public class SftpSession extends Object implements Session<com.jcraft.jsch.ChannelSftp.LsEntry>
Session
implementation. Wraps a JSCH session instance.Constructor and Description |
---|
SftpSession(org.springframework.integration.sftp.session.JSchSessionWrapper wrapper) |
SftpSession(com.jcraft.jsch.Session jschSession) |
Modifier and Type | Method and Description |
---|---|
void |
append(InputStream inputStream,
String destination)
Append to a file.
|
void |
close() |
boolean |
exists(String path)
Check if the remote file or directory exists.
|
boolean |
finalizeRaw()
Invoke after closing the InputStream from
Session.readRaw(String) . |
com.jcraft.jsch.ChannelSftp |
getClientInstance()
Get the underlying client library's client instance for this session.
|
String |
getHostPort()
Return the host:port pair this session is connected to.
|
boolean |
isOpen() |
com.jcraft.jsch.ChannelSftp.LsEntry[] |
list(String path) |
String[] |
listNames(String path) |
boolean |
mkdir(String remoteDirectory) |
void |
read(String source,
OutputStream os) |
InputStream |
readRaw(String source)
Retrieve a remote file as a raw
InputStream . |
boolean |
remove(String path) |
void |
rename(String pathFrom,
String pathTo) |
boolean |
rmdir(String remoteDirectory)
Remove a remote directory.
|
void |
setChannelConnectTimeout(java.time.Duration timeout)
Set the connect timeout.
|
boolean |
test()
Test the session is still alive, e.g.
|
void |
write(InputStream inputStream,
String destination) |
public SftpSession(com.jcraft.jsch.Session jschSession)
public SftpSession(org.springframework.integration.sftp.session.JSchSessionWrapper wrapper)
public void setChannelConnectTimeout(java.time.Duration timeout)
timeout
- the timeout to set.public boolean remove(String path) throws IOException
remove
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public com.jcraft.jsch.ChannelSftp.LsEntry[] list(String path) throws IOException
list
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public String[] listNames(String path) throws IOException
listNames
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public void read(String source, OutputStream os) throws IOException
read
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public InputStream readRaw(String source) throws IOException
Session
InputStream
.readRaw
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
source
- The path of the remote file.IOException
- Any IOException.public boolean finalizeRaw()
Session
Session.readRaw(String)
.
Required by some session providers.finalizeRaw
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
public void write(InputStream inputStream, String destination) throws IOException
write
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public void append(InputStream inputStream, String destination) throws IOException
Session
append
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
inputStream
- the stream.destination
- the destination.IOException
- an IO Exception.public void close()
public boolean isOpen()
public void rename(String pathFrom, String pathTo) throws IOException
rename
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public boolean mkdir(String remoteDirectory) throws IOException
mkdir
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
IOException
public boolean rmdir(String remoteDirectory) throws IOException
Session
rmdir
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
remoteDirectory
- The directory.IOException
- an IO exception.public boolean exists(String path)
Session
public com.jcraft.jsch.ChannelSftp getClientInstance()
Session
Object
to avoid significant changes to -file, -ftp, -sftp
modules, which would be required
if we added another generic parameter. Implementations should narrow the
return type.getClientInstance
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
public String getHostPort()
Session
getHostPort
in interface Session<com.jcraft.jsch.ChannelSftp.LsEntry>
public boolean test()
Session
Session.isOpen()
.