如何使用Mule通过REST通过HTTP上传多个文件? [英] How to upload multiple files via REST over HTTP using Mule?
问题描述
我有一个文件夹"MyFiles",其中有很多文件.现在,我需要通过REST over HTTP上传那些文件.该怎么办?
I have a folder say "MyFiles" where I have lots of files. Now I need to upload those file via REST over HTTP . What will be the approach?
我尝试了以下操作,但这是错误的
I tried the below but it is wrong
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<http:rest-service-component
serviceUrl="http://localhost:8280/rest/xyz"
httpMethod="POST">
</http:rest-service-component>
<http:endpoint host="localhost" port="5430" encoding="UTF-8"
method="POST" connector-ref="fileHttp" path="fileuploader" name="muleFileUploader">
</http:endpoint>
</flow>
请帮助.由于输入文件夹将包含多个文件,我们又如何实现呢?
Please help. Since the input folder will have multiple files, how can we achieve that also?
谢谢
推荐答案
您的流不使用文件入站终结点,而是使用通用(非进出)HTTP终结点,因此无法正常工作.
Your flow doesn't use a file inbound endpoint and uses a generic (non-in non-out) HTTP endpoint so there's no way this can work.
以下是成功将文件上传到HTTP端点的配置.没有object-to-byte-array-transformer
,我无法使其正常工作(同一文件一遍又一遍地被轮询-错误吗?),所以希望您的文件不会太大...
Below is a configuration that successfully uploads files to an HTTP endpoint. I can not make it work without the object-to-byte-array-transformer
(the same file gets polled over and over again - bug?), so I hope your files are not huge...
<flow name="fileUploader">
<file:inbound-endpoint path="/tmp/mule/in"
pollingFrequency="5000" moveToDirectory="/tmp/mule/done" />
<object-to-byte-array-transformer />
<http:outbound-endpoint address="http://..."
method="POST" exchange-pattern="request-response" />
</flow>
这篇关于如何使用Mule通过REST通过HTTP上传多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!