我可以在s3入站适配器中具有local-directory-expression吗?我的本地目录路径是一个表达式。如何在local-directory属性中分配表达式变量?
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"/>
答案 0 :(得分:0)
无法从消息中解析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"/>