spring-boot - s3 入站通道适配器中的本地目录表达式
问题描述
我可以在 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"/>
推荐阅读
- python - 如何从数据框中的列中提取强标签并附加或替换该单元格?
- java - 为 Box 类创建测试驱动程序并测试其所有方法
- c# - 在功能区按钮查找中禁用 excel 构建 (FindDialogExcel)
- python - 从 windguru 刮桌子
- python - 如何在 matplotlib 的箱线图中删除自定义标签下的数字 x 刻度?
- java - 无法测试宁静的服务
- azure - 在开发 .NET 核心 Azure 功能时脱机使用 Azure 密钥库机密
- css - 为范围旋钮 ionic-range 添加边框颜色
- java - DDD - java 9 模块项目组织
- python - 将 Datetime 列转换为仅在 Python 中的 DataFrame 中显示日期