s3 入站通道适配器中的本地目录表达式

Local Directory expression in s3 inbound channel adaptor

我可以在 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"/>