Reading Attachments in Mule

#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

Make Impossible States Impossible

NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent.

This is a phrase I first heard from David Khourshid in his talk at React Rally 2017 Infinitely Better UIs with Finite Automata: “Make impossible states impossible” (super great talk by the way, and xstate is awesome, and David is too). Googling around, it looks like it’s a pretty popular phrase in the Elm community, though I’m not sure who said it first. https://goo.gl/shdHKF

Deploying the Winds API to AWS ECS With Docker Compose

#ICYMI: Winds is a popular RSS and Podcast application provided by Stream — a service that allows you to build news and activity feeds. Winds is 100% open-source and the backend is easy to install in a local environment or in the cloud — a task that we will cover in this tutorial. To ensure that you make it through the tutorial, make sure to complete all of the prerequisites.

Prerequisites

As with any tutorial, there are some requirements that come with it. For this post, you’ll need to ensure that you have the following up and running, and ready to go prior to continuing on. If you decide to skip the requirements, you’ll likely get hung up at one spot — and we don’t want that to happen. https://goo.gl/LqH681