/
Configuring Amazon S3 Operations

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Configuring Amazon S3 Operations

This documentation is for Amazon S3 connector version 1.0.4. If you are using Amazon S3 connector version 1.0.5, go to the WSO2 Amazon S3 connector GitHub repository to view the latest documentation.



Connecting to Amazon S3

To use the Amazon S3 connector, add the <amazons3.init> element in your configuration before carrying out any Amazon S3 operations. This Amazon S3 configuration authenticates with Amazon S3 by specifying the AWS access key ID and secret access key ID, which are used for every operation. The signature is used with every request and thus differs based on the request the user makes.

init
<amazons3.init>
  <accessKeyId>ZZZZZZ</accessKeyId>
  <secretAccessKey>ZZZZZ</secretAccessKey>
  <methodType>GET</methodType>
  <contentType>application/xml</contentType>
  <addCharset>true</addCharset>
  <bucketName>test123</bucketName>
  <isXAmzDate>true</isXAmzDate>
  <expect>100-continue</expect>
  <contentMD5>ertyrtu</contentMD5>
  <xAmzSecurityToken></xAmzSecurityToken>
  <contentLength>2</contentLength>
  <host>s3.amazonaws.com</host>
  <xAmzAcl>public-read</xAmzAcl>
  <xAmzGrantRead>GrantRead</xAmzGrantRead>
  <xAmzGrantWrite>Grantwrite</xAmzGrantWrite>
  <xAmzGrantReadAcp>GrantReadAcp</xAmzGrantReadAcp>
  <xAmzGrantWriteAcp>GrantWriteAcp</xAmzGrantWriteAcp>
  <xAmzGrantFullControl>GrantFullControl</xAmzGrantFullControl>
</amazons3.init>
Properties
  • accessKeyId: AWS access key ID.
  • secretAccessKey: AWS secret access key.
  • methodType: HTTP method type.
  • contentType: Content type of the resource.
  • addCharset: Set to true to add the charset in the ContentType header of POST and HEAD methods when you are using the connector with ESB 4.9.0. 

  • bucketName: Name of the bucket.
  • isXAmzDate: Indicates whether the current date and time are considered to calculate the signature. Valid values: true or false.
  • expect: This header can be used only if a request is sent not to send the request body until it receives an acknowledgement. Valid value: 100-continue
  • contentMD5: Base64-encoded 128-bit MD5 digest of the message according to RFC 1864.
  • xAmzSecurityToken: The security token based on whether Amazon DevPay operations or temporary security credentials are used.
  • contentLength: Length of the message without the headers according to RFC 2616.
  • host: The path-style requests (s3.amazonaws.com) or virtual-style requests (BucketName.s3.amazonaws.com).
  • xAmzAcl: Sets the ACL of the bucket using the specified canned ACL.
  • xAmzGrantRead: Allows the specified grantee or grantees to list the objects in the bucket.
  • xAmzGrantWrite: Allows the specified grantee or grantees to create, overwrite, and delete any object in the bucket.
  • xAmzGrantReadAcp: Allows the specified grantee or grantees to read the bucket ACL.
  • xAmzGrantWriteAcp: Allows the specified grantee or grantees to write the ACL for the applicable bucket.
  • xAmzGrantFullControl: Allows the specified grantee or grantees the READ, WRITE, READ_ACP, and WRITE_ACP permissions on the bucket.

Additional information

Ensure that the following Axis2 configurations are added and enabled in the <ESB_HOME>/repository/conf/axis2/axis2.xml file.

Required message formatters
messageFormatters
<messageFormatter contentType="image/gif" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="img/gif" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="image/jpeg" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="image/png" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="image/ico" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="image/x-icon" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

<messageFormatter contentType="application/octet-stream" class="org.apache.axis2.format.BinaryFormatter"/>

<messageFormatter contentType="application/x-bittorrent" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
Required message builders
messageBuilders
<messageBuilder contentType="binary/octet-stream" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> 

<messageBuilder contentType="image/gif" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="img/gif" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="image/jpeg" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="image/png" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="image/ico" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="image/x-icon" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

<messageBuilder contentType="application/x-bittorrent" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

Note

If you are using ESB 4.9.0, append the charset UTF-8 to the contentType as follows:
<contentType>application/xml;charset=UTF-8</contentType>

Now that you have connected to Amazon S3, use the information in the following topics to perform various operations with the connector. 

Error codes

Error Code

Description

700001

IO exception caused by one of the following:

  • Failed attempt at reading from a file that does not exist.
  • Invalid file name provided.
  • Attempting to read the next token in a file when there are no more tokens.

700007

Invalid keys (invalid encoding, wrong length, uninitialized, etc.)

700008

Cryptographic algorithm is requested but is not available.

700009

Character encoding is not supported.

900001

Unspecified general exception.