Mule能够简单地移动/重命名文件吗?

时间:2013-12-10 20:18:18

标签: mule

有没有办法简单地“移动/重命名”Mule中的文件而不是副本?下面的流程执行副本,但我真正想要的是简单地重命名文件。该文件可能非常大。

<file:connector name="Global-StageToInput" fileAge="10000" autoDelete="true" pollingFrequency="30000"/>
<file:connector name="Global-FileInput" outputPattern="#[header:originalFilename]" />

<flow name="Global-MoveInputFiles">
    <file:inbound-endpoint connector-ref="Global-StageToInput" path="${stage}"/>
    <file:outbound-endpoint connector-ref="Global-FileInput" path="${input}"/>
</flow>

1 个答案:

答案 0 :(得分:0)

如果要将文件从一个目录移动到另一个目录,文件将从您正在移动的目录中消失。

可以使用入站端点

中的moveToDirectory来备份此文件

要重命名备份文件,您可以在入站端点

中使用moveToPattern

要在目标中重命名,您可以在出站端点中使用outputPattern 您可以使用以下链接获得更多想法

<file:inbound-endpoint connector-ref="input" path="/tmp/input" moveToDirectory="/tmp/backup" moveToPattern="#[header:originalFilename].backup"/>
<file:outbound-endpoint connector-ref="output" path="/tmp/output" outputPattern="#[function:datestamp]-#[header:originalFilename]"/>

http://www.mulesoft.org/documentation/display/current/File+Transport+Reference

http://www.mulesoft.org/documentation-3.2/display/32X/File+Transport+Reference

http://www.mulesoft.org/connectors/file-connector

如果只需要将文件从文件夹移动到另一个需要重命名文件名的文件。

然后使用以下代码

<file:inbound-endpoint connector-ref="input" path="/tmp/input"/>
<file:outbound-endpoint connector-ref="output" path="/tmp/output" outputPattern="#[function:datestamp]-#[header:originalFilename]"/>

只是出站端点中的模式。

只需输入和输出中的路径.Rest all不是必需的,并且可以使用链接的选项的混合和匹配。甚至连接器-ref也不是基本要求所必需的