0

我有这个 mule 流,它轮询源文件夹以读取我作为附件添加并通过 REST 调用发送的文本文件,我试图在不同的流中读取相同的附件,但入站附件为空,请查看代码并帮助我解决这个问题。

<flow name="createAttachment" doc:description="Reading file and sending as attachment.">
    <file:inbound-endpoint path="src/test/resources/in/attachment/" responseTimeout="10000" doc:name="File"/>
    <file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
 <!--    <set-attachment attachmentName="#[originalFilename]" value="#[payload]" contentType="multipart/form-data" doc:name="Attachment"/>  -->
  <set-attachment attachmentName="#[originalFilename]" value="#[payload]" contentType="multipart/form-data" doc:name="Attachment" />
    <http:request config-ref="HTTP_Request_Configuration" path="attachment/excel"  method="POST" doc:name="HTTP"/>
</flow>


<flow name="readAttachment">
 <http:listener config-ref="HTTP_Listener_Configuration" path="attachment/excel" allowedMethods="POST" parseRequest="false" />
    <set-payload value="#[message.inboundAttachments['myattachment.txt']]" doc:name="Retrieve Attachments"/> 
      <set-payload value="#[payload.getInputStream() ]" doc:name="Get Inputstream from Payload"/>
        <file:outbound-endpoint path="src/test/resources/out/attachment" responseTimeout="10000" doc:name="File" outputPattern="#[server.dateTime.toString()].pdf"/>

</flow>
4

1 回答 1

0

我使用了以下内容:

<flow name="readAttachment">
    <http:listener config-ref="HTTP_Listener_Configuration"
        path="/" allowedMethods="POST" parseRequest="false" doc:name="HTTP" />
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <logger message="#[payload]" level="INFO" doc:name="Logger" /><file:outbound-endpoint path="src/test/resources" connector-ref="File" responseTimeout="10000" doc:name="File"/>

</flow>

收到附件时,它会自动解析为有效负载,因此只是将字节数组转换为字符串的情况。

我希望这有帮助

于 2017-07-27T15:15:49.097 回答