INT-3726: Support Path for FileHeaders.FILENAME
JIRA: https://jira.spring.io/browse/INT-3726 Since the `FileHeaders.FILENAME` header is relaxed String, we can use any value there. For example some use-cases (e.g. unzipping) would like to use the relative path together with the file name to restore the original directory structure in the target directory using `FileWritingMessageHandler`. Use `resultFile.getParentFile().mkdirs()` in the `FileWritingMessageHandler` to recreate the directory hierarchy before the target file manipulating. Add Documentation Address PR comments
This commit is contained in:
committed by
Gary Russell
parent
2f56bb1329
commit
2be12160e9
@@ -459,17 +459,22 @@ Once setup, the `DefaultFileNameGenerator` will employ the following resolution
|
||||
|
||||
When using the XML namespace support, both, the _File Outbound Channel Adapter_ and the _File Outbound Gateway_ support the following two mutually exclusive configuration attributes:
|
||||
|
||||
* `filename-generator` (a reference to a `FileNameGenerator`) implementation)
|
||||
* `filename-generator` (a reference to a `FileNameGenerator` implementation)
|
||||
* `filename-generator-expression` (an expression evaluating to a `String`)
|
||||
|
||||
|
||||
|
||||
While writing files, a temporary file suffix will be used (default: `.writing`).
|
||||
It is appended to the filename while the file is being written.
|
||||
To customize the suffix, you can set the _temporary-file-suffix_ attribute on both the _File Outbound Channel Adapter_ and the _File Outbound Gateway_.
|
||||
|
||||
NOTE: When using the _APPEND_ file _mode_, the _temporary-file-suffix_ attribute is ignored, since the data is appended to the file directly.
|
||||
|
||||
Starting with _version 4.2.5_ the generated file name (as a result of `filename-generator`/`filename-generator-expression`
|
||||
evaluation) can represent a _sub-path_ together with the target file name.
|
||||
It is used as a second constructor argument for `File(File parent, String child)` as before, but in the past we didn't
|
||||
created (`mkdirs()`) directories for _sub-path_ assuming only the _file name_.
|
||||
This approach is useful for cases when we need to restore the file system tree according the source directory.
|
||||
For example we unzipping the archive and want to save all file in the target directory at the same order.
|
||||
|
||||
[[file-writing-output-directory]]
|
||||
==== Specifying the Output Directory
|
||||
|
||||
@@ -478,8 +483,6 @@ Both, the _File Outbound Channel Adapter_ and the _File Outbound Gateway_ provid
|
||||
* _directory_
|
||||
* _directory-expression_
|
||||
|
||||
|
||||
|
||||
NOTE: The _directory-expression_ attribute is available since Spring Integration 2.2.
|
||||
|
||||
*Using the directory attribute*
|
||||
|
||||
@@ -47,3 +47,8 @@ See <<tcp-events>> for more information.
|
||||
The `destination-expression` and `socket-expression` are now available for the `<int-ip:udp-outbound-channel-adapter>`.
|
||||
See <<udp-adapters>> for more information.
|
||||
|
||||
==== File Changes
|
||||
|
||||
The generated file name for the `FileWritingMessageHandler` can represent _sub-path_ to save the desired directory
|
||||
structure for file in the target directory.
|
||||
See <<file-writing-file-names>> for more information.
|
||||
|
||||
Reference in New Issue
Block a user