我可以在 s3 入站适配器中使用本地目录表达式吗?我的本地目录路径是一个表达式。如何在本地目录属性中分配表达式变量?
Config details below
<int-aws:s3-inbound-channel-adapter id="s3FileInbound"
channel="s3FilesChannel"
session-factory="s3SessionFactory"
auto-create-local-directory="false"
delete-remote-files="false"
preserve-timestamp="true"
filter="acceptOnceFilter"
local-directory="local_directory"
auto-startup="false"
remote-directory="s3_bucket"/>
无法从邮件中解析local-directory
,因为邮件是在将远程文件复制到该local-directory
之后创建的。
此属性可用于构建相对本地路径:
<xsd:attribute name="local-filename-generator-expression">
<xsd:annotation>
<xsd:documentation>
Allows you to provide a SpEL expression to
generate the file name of
the local (transferred) file. The root
object of the SpEL
evaluation is the name of the original
file.
For example, a valid expression would be "#this.toUpperCase() +
'.a'" where #this represents the
original name of the remote
file.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
因此,您可以将local-directory
作为硬盘驱动器上的根路径,并从那里构建目标目录以及本地文件系统的文件名。
另请参阅 https://jira.spring.io/browse/INT-4025 了解更多信息。
更新
我会这样配置它:
<int-aws:s3-inbound-channel-adapter
local-directory="C:/"
local-filename-generator-expression="'my_local_directory/' + #this"/>