Mule文件入站到HTTP出站

时间:2014-07-04 16:45:55

标签: mule

我有一个案例需要在我的文件系统上轮询目录。添加到该目录的每个文件都需要发布到HTTP端点。

HTTP端点在" / rest / latest / file"上可用。使用postman,我已经验证了REST调用可以使用以下设置:

  • POST
  • basic auth
  • 形状数据:
    • key = file
    • value =从我的文件系统中选择一个文件(使用对话框)

我的骡子流目前看起来像这样:

<file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" moveToPattern="#[message.inboundProperties['originalFilename']].backup" moveToDirectory="src/main/resources/output" doc:name="File"/>
<flow name="importdataqualityresultsFlow1" doc:name="importdataqualityresultsFlow1">
    <file:inbound-endpoint path="src/main/resources/input" responseTimeout="10000" doc:name="File"/>
    <set-payload value="#[['file' :#[message.inboundAttachments['text.txt']]]]" doc:name="Set Payload"/>
    <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="80" path="rest/latest/file" method="POST" user="Admin" password="admin" contentType="application/form-data" doc:name="HTTP"/>
</flow>

我可以在我的应用程序日志中告诉用户使用基本身份验证登录,然后我获得堆栈跟踪。

非常感谢任何帮助/指示。

1 个答案:

答案 0 :(得分:2)

您需要使用表单字段创建地图有效内容:

<flow name="importdataqualityresultsFlow1">
  <file:inbound-endpoint path="src/main/resources/input" />
  <object-to-string-transformer />
  <set-payload value="#[['file': message.payload]]" />
  <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="80" path="rest/latest/file" method="POST" user="Admin" password="admin" contentType="application/form-data" />
</flow>
相关问题