Class FtpSession
java.lang.Object
org.springframework.integration.ftp.session.FtpSession
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Session<org.apache.commons.net.ftp.FTPFile>
Implementation of
Session
for FTP.- Since:
- 2.0
- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Den Ivanov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(InputStream inputStream, String path) Append to a file.void
close()
boolean
Check if the remote file or directory exists.boolean
Invoke after closing the InputStream fromSession.readRaw(String)
.org.apache.commons.net.ftp.FTPClient
Get the underlying client library's client instance for this session.Return the host:port pair this session is connected to.boolean
isOpen()
org.apache.commons.net.ftp.FTPFile[]
String[]
boolean
void
read
(String path, OutputStream fos) Retrieve a remote file as a rawInputStream
.boolean
void
boolean
Remove a remote directory.boolean
test()
Test the session is still alive, e.g.void
write
(InputStream inputStream, String path)
-
Constructor Details
-
FtpSession
public FtpSession(org.apache.commons.net.ftp.FTPClient client)
-
-
Method Details
-
remove
- Specified by:
remove
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
list
- Specified by:
list
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
listNames
- Specified by:
listNames
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
readRaw
Description copied from interface:Session
Retrieve a remote file as a rawInputStream
.- Specified by:
readRaw
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Parameters:
source
- The path of the remote file.- Returns:
- The raw inputStream.
- Throws:
IOException
- Any IOException.
-
finalizeRaw
Description copied from interface:Session
Invoke after closing the InputStream fromSession.readRaw(String)
. Required by some session providers.- Specified by:
finalizeRaw
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Returns:
- true if successful.
- Throws:
IOException
- Any IOException.
-
write
- Specified by:
write
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
append
Description copied from interface:Session
Append to a file.- Specified by:
append
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Parameters:
inputStream
- the stream.path
- the destination.- Throws:
IOException
- an IO Exception.
-
close
public void close() -
isOpen
public boolean isOpen() -
rename
- Specified by:
rename
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
mkdir
- Specified by:
mkdir
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Throws:
IOException
-
rmdir
Description copied from interface:Session
Remove a remote directory.- Specified by:
rmdir
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Parameters:
directory
- The directory.- Returns:
- True if the directory was removed.
- Throws:
IOException
- an IO exception.
-
exists
Description copied from interface:Session
Check if the remote file or directory exists.- Specified by:
exists
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Parameters:
path
- the remote path.- Returns:
true
orfalse
if remote path exists or not.- Throws:
IOException
- an IO exception during remote interaction.
-
getClientInstance
public org.apache.commons.net.ftp.FTPClient getClientInstance()Description copied from interface:Session
Get the underlying client library's client instance for this session. Returns anObject
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.- Specified by:
getClientInstance
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Returns:
- The client instance.
-
getHostPort
Description copied from interface:Session
Return the host:port pair this session is connected to.- Specified by:
getHostPort
in interfaceSession<org.apache.commons.net.ftp.FTPFile>
- Returns:
- the host:port pair this session is connected to.
-
test
public boolean test()Description copied from interface:Session
Test the session is still alive, e.g. when checking out from a pool. The default implementation simply delegates toSession.isOpen()
.
-