2017-07-27 55 views
0

我有這個騾流,其中它輪詢的源文件夾讀取我作爲附件添加並通過REST調用發送的文本文件,我試圖讀取相同的附件在不同的流程中,但入站​​附件會變爲空,請查看代碼並在此幫助我。騾流不能讀取入站attachmnet

<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> 

回答

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> 

當接收到該附件將其自動解析是有效載荷,所以這只是轉動字節數組的情況下串。

我希望這可以幫助