Amazon S3 Connector 5.7 Examples

The following example shows how to store an image from a URL in Amazon S3, and retrieve and display the image.


For this example to work in Anypoint Studio, you must provide Amazon Web Services credentials. You can either:

  • Replace the variables with their values in the code.

  • Provide the values for each variable in the src/main/resources/ file.

Example Steps

Studio 7 Visual Studio Icon Flow. The flow shows Listener
  1. Create a new Mule project in Studio.

  2. Drag an HTTP > Listener into the canvas, and select it to open the properties editor.

  3. Add a new HTTP Listener Config global element:

    1. In General Settings, click the + button:

    2. Configure the following HTTP parameters, retain the default values for the other fields, and click OK.

      Field Value






    3. Reference the HTTP Listener Configuration global element. In the General tab, specify the / Path.

  4. Drag an Amazon S3 connector into the flow, and double-click the connector to open its properties editor.

  5. If you don’t have an existing Amazon S3 connector global element to choose, click the + sign next to Extension Configuration field.

  6. Configure the global element properties, and then click OK.

  7. Configure the connector parameters:

    Connector Properties - General tab
    Field Value

    Display Name

    Name for the connector instance, such as Create bucket.

    Extension Configuration

    Global configuration for the connector.

    Bucket Name



    Region, for example US_STANDARD (default).

    Canned ACL

    PRIVATE (default) access control list. A canned ACL is a predefined grant.

  8. Add an HTTP > Connector to request the MuleSoft logo from MuleSoft.

    HTTP > Connector - General Tab
    Field Value

    Display Name

    Name for the connector instance. In this example, HTTP > Connector is named Get MuleSoft logo.


    Configuration with the Host as, Protocol as HTTPS, and Port as 80.

    URL or Path




    Target Value


  9. Drag another Amazon S3 connector to create the requested MuleSoft logo in the selected Amazon S3 Bucket.

    S3 Connector Create Logo Object in S3 Bucket General Tab
    Field Value

    Display Name

    Name of your choice. In this example, the S3 connector is named Create logo object in S3 bucket.

    Extension Configuration

    Global configuration that you created.

    Bucket Name






    Canned ACL

    PRIVATE (default)

    Storage Class

    STANDARD (default)

  10. Add another Amazon S3 connector to get the newly created MuleSoft logo image object from the bucket:

    S3 Connector Get Image General Tab
    Field Value

    Display Name

    Name for the connector instance. In this example the S3 connector is called Get Image.

    Extension Configuration

    Global configuration you create.

    Bucket Name




  11. Add another Amazon S3 connector to delete the bucket. Because the delete bucket operation’s return type is void, the payload contains the object returned by the get image operation.

    S3 Connector Delete S3 Bucket General Tab
    Field Value

    Bucket Name




XML for the Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:s3=""
  <configuration-properties file=""/>
  <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="DOC_ID">
    <http:listener-connection host="" port="8081"/>
  <s3:config name="Amazon_S3_Configuration" doc:name="Amazon S3 Configuration" doc:id="DOC_ID">
    <s3:basic-connection accessKey="${config.accessKey}" secretKey="${config.secretKey"/>
  <http:request-config name="HTTPS_Request_Configuration" doc:name="HTTP Request configuration" doc:id="DOC_ID">
    <http:request-connection protocol="HTTPS" host=""/>
  <flow name="s3docuFlow" doc:id="DOC_ID">
    <http:listener config-ref="HTTP_Listener_config" path="/" doc:name="Listener" doc:id="DOC_ID"/>
    <s3:create-bucket config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}"
    doc:name="Create bucket" doc:id="DOC_ID"/>
    <http:request method="GET" path="/sites/default/files/new-application_network_diagram-01.svg"
    doc:name="Request" doc:id="DOC_ID" config-ref="HTTPS_Request_Configuration"/>
    <s3:create-object config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}" key="muledevelogo"
    doc:name="Create object" doc:id="DOC_ID"/>
    <s3:get-object config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}" key="muledevelogo"
    doc:name="Get object" doc:id="DOC_ID"/>
    <s3:delete-bucket config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}"
    doc:name="Delete bucket" doc:id="DOC_ID" force="true"/>