---
schema_version: "1"
id: 5c7575e11be3d19de85966197029fabf4d13330fea6f33a3166995f3b1f007d1
title: Amazon S3 Connector 7.1 Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/amazon-s3-connector/7.1/amazon-s3-connector-examples.md
canonical_url: https://docs.mulesoft.com/amazon-s3-connector/7.1/amazon-s3-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2747ea35038f5246856861fcb1403e2121b91af7f4da01dbaaf191cd6f7102b3
description: MuleSoft Documentation Site
release: "7.1"
latest: false
---
---
product: Amazon S3 Connector
version: 7.1
---

# Amazon S3 Connector 7.1 Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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

## Before You Begin

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/mule-artifact.properties` file.

## Example Steps

![Studio 7 Visual Studio Icon Flow. The flow shows HTTP Listener, Create bucket, Get MuleSoft logo, Create logo object in S3 bucket, Get Image, Delete object and Delete S3 bucket.](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/flow.png)

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**:

        <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Name</p></td><td><p>HTTP_Listener_Configuration</p></td></tr><tr><td><p>Host</p></td><td><p>127.0.0.1</p></td></tr><tr><td><p>Port</p></td><td><p>8081</p></td></tr></tbody></table>

    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](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/s3_config.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Name</p></td><td><p>Name for the connector instance, such as <code>Amazon_S3_Configuration</code>.</p></td></tr><tr><td><p>General</p></td><td><p>General configuration for the connector.</p></td></tr><tr><td><p>Region Endpoint</p></td><td><p>Region, for example, <code>us-east-1</code> (default).</p></td></tr><tr><td><p>Access key</p></td><td><p>Connection access key.</p></td></tr><tr><td><p>Secret key</p></td><td><p>Connection secret key.</p></td></tr></tbody></table>

8.  Drag the **Create Bucket** operation into the flow.

    ![S3 Connector Create Bucket in S3 General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/create_bucket.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Display name of your choice, such as <code>Create new bucket</code>.</p></td></tr><tr><td><p>Connector configuration</p></td><td><p>Global configuration for the connector.</p></td></tr><tr><td><p>Bucket name</p></td><td><p>Name of the newly created bucket.</p></td></tr><tr><td><p>ACL</p></td><td><p>PRIVATE (default) access control list. A canned ACL is a predefined grant.</p></td></tr></tbody></table>

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

    ![HTTP Connector General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/request.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Name for the connector instance. In this example, HTTP &gt; Connector is named <code>Get MuleSoft logo</code>.</p></td></tr><tr><td><p>Configuration</p></td><td><p>Configuration with the <strong>Host</strong> as <code>developer.mulesoft.com</code>, <strong>Protocol</strong> as <code>HTTPS</code>, and <strong>Port</strong> as <code>80</code>.</p></td></tr><tr><td><p>URL or Path</p></td><td><p><code>/sites/all/themes/muletheme/images/mulesoft_dev_logo_v2.svg</code>.</p></td></tr></tbody></table>

10. Drag the **Put Object** operation into the flow to create the requested MuleSoft logo in the
    selected Amazon S3 bucket.

    ![S3 Connector Create Logo Object in S3 Bucket General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/put_object.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Display name of your choice, such as <code>Create logo object in S3 bucket</code>.</p></td></tr><tr><td><p>Connector Configuration</p></td><td><p>Global configuration for the connector.</p></td></tr><tr><td><p>Bucket Name</p></td><td><p>Name of the bucket in which the new object is created.</p></td></tr><tr><td><p>Key</p></td><td><p>Name of the newly created object.</p></td></tr><tr><td><p>Content</p></td><td><p>Content of the object.</p></td></tr><tr><td><p>Object ACL</p></td><td><p>Access control list.</p></td></tr></tbody></table>

11. Drag the **Get Object** operation into the flow to get the newly created MuleSoft logo image
    object from the bucket.

    ![S3 Connector Get Image General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/get_object.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Display name of your choice, such as <code>Get Image</code>.</p></td></tr><tr><td><p>Connector Configuration</p></td><td><p>Global configuration for the connector.</p></td></tr><tr><td><p>Bucket Name</p></td><td><p>Name of the bucket in which an object is stored.</p></td></tr><tr><td><p>Object Key</p></td><td><p>Name of the object to get.</p></td></tr></tbody></table>

12. Drag the **Delete Object** operation into the flow to delete the object. Because the **Delete
    Object** operation’s return type is void, the payload contains the object returned by the **Get
    Object** operation.

    ![S3 Connector Delete S3 Bucket General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/delete_object.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Display name of your choice, such as <code>Delete created object</code>.</p></td></tr><tr><td><p>Connector Configuration</p></td><td><p>Global configuration for the connector.</p></td></tr><tr><td><p>Bucket Name</p></td><td><p>Name of the bucket in which an object is stored.</p></td></tr><tr><td><p>Object Name</p></td><td><p>Name of the object to delete.</p></td></tr></tbody></table>

13. Drag the **Delete Bucket** operation into the flow to delete the bucket. Because the **Delete
    Bucket** operation’s return type is void, the payload contains the object returned by the **Get
    Object** operation.

    ![S3 Connector Delete S3 Bucket General Tab](/mulesoft/current/en-us/amazon-s3-connector/7.1/_images/delete_bucket.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p>Display name of your choice, such as <code>Delete created bucket</code>.</p></td></tr><tr><td><p>Connector Configuration</p></td><td><p>Global configuration for the connector.</p></td></tr><tr><td><p>Bucket Name</p></td><td><p>Name of the bucket to delete.</p></td></tr></tbody></table>

## 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
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:s3="http://www.mulesoft.org/schema/mule/s3"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/s3 http://www.mulesoft.org/schema/mule/s3/current/mule-s3.xsd">
	<http:listener-config name="HTTP_Listener_config"
		doc:name="HTTP Listener config" doc:id="DOC_ID">
		<http:listener-connection host="0.0.0.0"
			port="8081" />
	</http:listener-config>
	<configuration-properties doc:name="Configuration properties" doc:id="DOC_ID" file="mule-artifact.properties" />
	<s3:config name="Amazon_S3_Configuration" doc:name="Amazon S3 Configuration" doc:id="DOC_ID" >
		<s3:connection accessKey="${config.accessKey}" secretKey="${config.secretKey}" />
	</s3:config>
	<http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="DOC_ID">
		<http:request-connection protocol="HTTPS" host="developer.mulesoft.com"/>
	</http:request-config>
	<flow name="docu-demoFlow" doc:id="DOC_ID" >
		<http:listener doc:name="Listener" doc:id="DOC_ID" config-ref="HTTP_Listener_config" path="/"/>
		<s3:create-bucket doc:name="Create new bucket" doc:id="DOC_ID" config-ref="Amazon_S3_Configuration" bucketName="${bucket.name}" acl="PRIVATE"/>
		<http:request method="GET" doc:name="Get Mulesoft logo" doc:id="DOC_ID" path="/sites/all/themes/muletheme/images/mulesoft_dev_logo_v2.svg" config-ref="HTTP_Request_configuration"/>
		<s3:put-object doc:name="Create logo object in S3 bucket" doc:id="DOC_ID" config-ref="Amazon_S3_Configuration" bucketName="${bucket.name}" key="${file.name}" objectACL="PRIVATE"/>
		<s3:get-object doc:name="Get image" doc:id="DOC_ID" config-ref="Amazon_S3_Configuration" bucketName="${bucket.name}" key="${file.name}"/>
		<s3:delete-object doc:name="Delete created object" doc:id="DOC_ID" config-ref="Amazon_S3_Configuration" bucketName="${bucket.name}" key="${file.name}"/>
		<s3:delete-bucket doc:name="Delete created bucket" doc:id="DOC_ID" config-ref="Amazon_S3_Configuration" bucketName="${bucket.name}"/>
	</flow>
</mule>
```

## See Also

- [Salesforce Help](https://help.salesforce.com)

- [Amazon Default Provider Credential Chain](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html)

- [Amazon Access Control List (ACL) overview](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html)
