Cloud Connector of the Week: Amazon S3

motif

We thought about creating a new section on our blog for showcasing certain connectors which we think deserve some recognition. Unlike some of our other posts we won’t dwell into fully working Mule solutions, but rather talk about just snippets of them.

This week will start with S3. As many of you know there used to be an S3 transport for Mule 2.x and many people loved it. They loved it so much that we took really seriously bring it back as a cloud connector and let me tell you. It is better than ever… Shall we?

Amazon’s S3 is an online storage service. The first one of its kind to became really popular among developers, before Google had its offering, before Azure existed and way before iCloud came to be.

S3’s design aims to provide scalability, high availablity, and low latency. S3 can store objects up to 5 terabytes in size alongside up to 2kb of metadata. Objects inside S3 are organized into buckets. Each bucket is identified by a unique user-assigned key.

S3 offers a REST-style HTTP interface and a SOAP interface which can be used to create, list and retrieve the objects and the buckets. Each bucket has an access control list associated with it which authorizes each action.

It is important to note that objects inside S3 buckets are accesible via start HTTP client (like web browsers). It is because of this that S3 has replaced many static web hosting infrastructure in the cloud.

Adding S3 Cloud Connector to your Mule App

So, what if you want to use the cloud connector in your Mule app? Really easy, first add the following snippet to your Maven POM:

then add the connector as a dependency:

That’s it!

Using S3 Cloud Connector in your flow

The first thing you should do is declare the S3 namespace in your flow as follows:

then, we need to declare the connector and configure it (remember that you can have as many configurations as you want):

Notice that in the previous example we are using property placeholders loading the actual values of the configuration from properties file.

List Buckets

Answers a list of all Amazon S3 buckets that the authenticated sender of the request owns.

List Objects inside a Bucket

Lazily lists all objects for a given prefix. As S3 does not limit in any way the number of objects, such listing can retrieve an arbitrary amount of objects, and may need to perform extra calls to the api while it is iterated.

Notice that we are retrieving the name of the bucket from the “bucketName” property of a JSON object. We use Mule expressions to query the message.

Create Object

This operation will upload content to S3.

This snippet will upload the message’s payload as content to a file named by fileName flow variable inside the bucketName flow variable.

Delete Object

And of course, last but not least is the ability for deleting objects.

More Info

This is just a kind preview of the kind of things you can do with our S3 connector. I only showed you 4 operations but the connector itself has well over 19. It can manage buckets, access control lists for those buckets, object versions and much more. If you like to know more about S3 you can check Amazon’s page here:

Amazon Simple Storage Service (S3)

Also, for more info about our connector you can cheeck our page at MuleForge:

S3 Cloud Connector

And for the curious out there we offer full source code for the connector along with two full examples at our GitHub repository:

S3 GitHub Repository

S3 Example 1

S3 Example 2

Thanks for reading! Let us know what you think about this new section in our comments. See ya next week!


We'd love to hear your opinion on this post