[[sftp-rft]]
= Using `RemoteFileTemplate`
:page-section-summary-toc: 1

Spring Integration version 3.0 provides a new abstraction over the `SftpSession` object.
The template provides methods to send, retrieve (as an `InputStream`), remove, and rename files.
In addition, we provide an `execute` method to let the caller run multiple operations on the session.
In all cases, the template takes care of reliably closing the session.
For more information, see the https://docs.spring.io/spring-integration/api/org/springframework/integration/file/remote/RemoteFileTemplate.html[Javadoc for `RemoteFileTemplate`] There is a subclass for SFTP: https://docs.spring.io/spring-integration/api/org/springframework/integration/sftp/session/SftpRemoteFileTemplate.html[`SftpRemoteFileTemplate`].

We added additional methods in version 4.1, including `getClientInstance()`.
It provides access to the underlying `ChannelSftp`, which enables access to low-level APIs.

Version 5.0 introduced the `RemoteFileOperations.invoke(OperationsCallback<F, T> action)` method.
This method lets several `RemoteFileOperations` calls be called in the scope of the same thread-bounded `Session`.
This is useful when you need to perform several high-level operations of the `RemoteFileTemplate` as one unit of work.
For example, `AbstractRemoteFileOutboundGateway` uses it with the `mput` command implementation, where we perform a `put` operation for each file in the provided directory and recursively for its sub-directories.
See the https://docs.spring.io/spring-integration/api/org/springframework/integration/file/remote/RemoteFileTemplate.html#invoke-org.springframework.integration.file.remote.OperationsCallback-[Javadoc] for more information.

