#ICYDK: Let’s say there is a requirement to handle a multipart request. As the request is received by Mule, the attachments are saved in an object called InboundAttchments, which is part of Mule Message.
Configuration
* Create a Mule flow with an HTTP listener.
* First, to read the total attachments received. Drop a logger after HTTP and write #[message.inboundAttachments.size()] in the logger message.
* To read the contents of attachment(s). Add a For Each. It will loop over the inbound Attachments object and read them one by one. Give #[message.inboundAttachments] against collection in properties tab.
* Inside the For Each scope, place a logger to read the contents using #[message.payloadAs(java.lang.String)]. Reading the payload using #[payload] will return an object.
Getting Attachment Metadata
* Attachment Name To get the name of attachment, we can use the variable key, which is auto-generated by Mule inside the For Each scope#[flowVars.key] or #[payload.dataSource.part.fileName]
* Attachment size (in Bytes) To get the attachment size, we have to read the payload and use the getBytes method #[message.payloadAs(java.lang.String).getBytes().length] or #[payload.dataSource.part.size]
* Content Type To get the content type of the attachment: #[payload.dataSource.part.contentType]
Flow XML
Thanks, and let me know your thoughts in the comments section! https://goo.gl/H6SqEa #DataIntegration #ML
