How send a file in an HTTP request and upload it to file server via FTP in Mule

后端 未结 1 1552
心在旅途
心在旅途 2021-01-28 18:22

I want to send a file in a HTTP POST request and then have Mule upload the file to a file directory on a server using FTP. It looks like the FTP connector saves the payload to

相关标签:
1条回答
  • 2021-01-28 19:01

    RAML to send multiple files to Mule api/endpoint could be defined as mentioned in answer to the post below-

    Send multiple Files in HTTP request using RAML

    To read these files in Mule api,you can use a for-each construct,something like below could be useful:

    <foreach doc:name="For Each" collection="#[message.inboundAttachments]">
           <set-payload value="#[payload.dataSource.content]" doc:name="Set Payload"/>
           <byte-array-to-string-transformer doc:name="Byte Array to String"/>
           <logger message="Content :- #[payload]" level="INFO" doc:name="Logger"/>
    
    </foreach>
    

    Once read you can edit or transform the file as required and add it as attachment using set-attachment

    <set-attachment attachmentName="requiredFile.xml" value="#[payload]" contentType="text/xml" doc:name="Attachment"/>
    

    And then you can send it to required FTP connector.

    0 讨论(0)
提交回复
热议问题