GH-2996: Add Resource for remote file transfer (#3231)

* GH-2996: Add Resource for remote file transfer

Fixes https://github.com/spring-projects/spring-integration/issues/2996

* Fix `RemoteFileTemplate.send()` to support a `Resource` payload
for remote file transferring content
* Code style clean up for `RemoteFileTemplate`
* Remove `volatile` for configuration properties for better performance
* Change a `charset` to the `Charset` for only once conversion from string
during configuration phase
* Fix (S)FTP tests for new functionality
* Change affected tests to JUnit 5
* Document a new feature; mention all the supported types and `FileExistsMode` constants

* * Fix language in `whats-new.adoc`
This commit is contained in:
Artem Bilan
2020-03-31 16:09:07 -04:00
committed by GitHub
parent 63f8907e88
commit 6d5690fd58
8 changed files with 171 additions and 122 deletions

View File

@@ -821,7 +821,9 @@ The FTP outbound channel adapter supports the following payloads:
* `java.io.File`: The actual file object
* `byte[]`: A byte array that represents the file contents
* `java.lang.String`: Text that represents the file contents.
* `java.lang.String`: Text that represents the file contents
* `java.io.InputStream`: a stream of data to transfer to remote file
* `org.springframework.core.io.Resource`: a resource for data to transfer to remote file
The following example shows how to configure an `outbound-channel-adapter`:
@@ -859,7 +861,9 @@ By default, an existing file is overwritten.
The modes are defined by the `FileExistsMode` enumeration, which includes the following values:
* `REPLACE` (default)
*`APPEND`
* `REPLACE_IF_MODIFIED`
* `APPEND`
* `APPEND_NO_FLUSH`
* `IGNORE`
* `FAIL`

View File

@@ -822,6 +822,8 @@ Similar to the FTP outbound adapter, the SFTP outbound channel adapter supports
* `java.io.File`: The actual file object
* `byte[]`: A byte array that represents the file contents
* `java.lang.String`: Text that represents the file contents
* `java.io.InputStream`: a stream of data to transfer to remote file
* `org.springframework.core.io.Resource`: a resource for data to transfer to remote file
The following example shows how to configure an SFTP outbound channel adapter:
@@ -852,7 +854,15 @@ In the preceding example, we define the `remote-filename-generator-expression` a
Starting with version 4.1, you can specify the `mode` when you transferring the file.
By default, an existing file is overwritten.
The modes are defined by the `FileExistsMode` enumeration, which has the following values: `REPLACE` (default), `APPEND`, `IGNORE`, and `FAIL`.
The modes are defined by the `FileExistsMode` enumeration, which includes the following values:
* `REPLACE` (default)
* `REPLACE_IF_MODIFIED`
* `APPEND`
* `APPEND_NO_FLUSH`
* `IGNORE`
* `FAIL`
With `IGNORE` and `FAIL`, the file is not transferred.
`FAIL` causes an exception to be thrown, while `IGNORE` silently ignores the transfer (although a `DEBUG` log entry is produced).

View File

@@ -126,3 +126,9 @@ See <<./mqtt.adoc#mqtt-ack-mode,Manual Acks>> for more information.
The outbound adapter now publishes a `MqttConnectionFailedEvent` when a connection can't be created, or is lost.
Previously, only the inbound adapter did so.
See <<./mqtt.adoc#mqtt-events,MQTT Events>>.
[[x5.3-sftp]]
=== (S)FTP Changes
The `FileTransferringMessageHandler` (for FTP and SFTP, for example) in addition to `File`, `byte[]`, `String` and `InputStream` now also supports an `org.springframework.core.io.Resource`.
See <<./sftp.adoc#sftp,SFTP Support>> and <<./ftp.adoc#ftp,FTP Support>> for more information.