Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
h2. S3 Component
*Available as of Camel 2.8*

The S3 component supports storing and retrieving objetcs from/to [Amazon's S3|http://aws.amazon.com/s3] service.

{info:title=Prerequisites}
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon S3. More information are available at [Amazon S3|http://aws.amazon.com/s3].
{info}

h3. URI Format
{code}
aws-s3://bucket-name[?options]
{code}
The bucket will be created if it don't already exists.
You can append query options to the URI in the following format, ?options=value&option2=value&...

h3. URI Options
|| Name || Default Value || Context || Description ||
|amazonS3Client | {{null}} | Shared | Reference to a {{com.amazonaws.services.sqs.AmazonS3Client}} in the [Registry]. |
|accessKey | {{null}} | Shared | Amazon AWS Access Key |
|secretKey | {{null}} | Shared | Amazon AWS Secret Key |
|amazonS3Endpoint | {{null}} | Shared | The region with which the AWS-S3 client wants to work with. |
|region | {{null}} | Producer | The region who the bucket is located. This option is used in the {{com.amazonaws.services.s3.model.CreateBucketRequest}}. |
|deleteAfterRead | {{true}} | Consumer | Delete objects from S3 after it has been retrieved. |
|maxMessagesPerPoll| 10 | Consumer | The maximum number of objects which can be retrieved in one poll. Used in in the {{com.amazonaws.services.s3.model.ListObjectsRequest}}. |

{info:title=Required S3 component options}
You have to provide the amazonS3Client in the [Registry] or your accessKey and secretKey to access the [Amazon's S3|http://aws.amazon.com/s3].
{info}

h3. Batch Consumer
This component implements the [Batch Consumer].

This allows you for instance to know how many messages exists in this batch and for instance let the [Aggregator] aggregate this number of messages.

h3. Usage
h4. Message headers evaluated by the S3 producer
{div:class=confluenceTableSmall}
|| Header || Type || Description ||
| {{CamelAwsS3Key}} | {{String}} | The key under which this object will be stored. |
| {{CamelAwsS3ContentLength}} | {{Long}} | The content length this object. |
| {{CamelAwsS3ContentType}} | {{String}} | The content type of this object. |
{div}

h4. Message headers set by the S3 producer
{div:class=confluenceTableSmall}
|| Header || Type || Description ||
| {{CamelAwsS3ETag}} | {{String}} | The ETag value for the newly uploaded object. |
| {{CamelAwsS3VersionId}} | {{String}} | The *optional* version ID of the newly uploaded object. |
{div}

h4. Message headers set by the S3 consumer
{div:class=confluenceTableSmall}
|| Header || Type || Description ||
| {{CamelAwsS3Key}} | {{String}} | The key under which this object is stored. |
| {{CamelAwsS3BucketName}} | {{String}} | The name of the bucket in which this object is contained. |
| {{CamelAwsS3ETag}} | {{String}} | The hex encoded 128-bit MD5 digest of the associated object according to RFC 1864. This data is used as an integrity check to verify that the data received by the caller is the same data that was sent by Amazon S3. |
| {{CamelAwsS3LastModified}} | {{Date}} | The value of the Last-Modified header, indicating the date and time at which Amazon S3 last recorded a modification to the associated object. |
| {{CamelAwsS3VersionId}} | {{String}} | The version ID of the associated Amazon S3 object if available. Version IDs are only assigned to objects when an object is uploaded to an Amazon S3 bucket that has object versioning enabled. |
| {{CamelAwsS3ContentType}} | {{String}} | The Content-Type HTTP header, which indicates the type of content stored in the associated object. The value of this header is a standard MIME type. |
| {{CamelAwsS3ContentMD5}} | {{String}} | The base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864. This data is used as a message integrity check to verify that the data received by Amazon S3 is the same data that the caller sent. |
| {{CamelAwsS3ContentLength}} | {{Long}} | The Content-Length HTTP header indicating the size of the associated object in bytes. |
| {{CamelAwsS3ContentEncoding}} | {{String}} | The *optional* Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field. |
| {{CamelAwsS3ContentDisposition}} | {{String}} | The *optional* Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as. |
| {{CamelAwsS3ContentControl}} | {{String}} | The *optional* Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain. |
{div}

h4. Advanced AmazonS3Client configuration
If your Camel Application is running behind a firewall or if you need to have more control over the AmazonS3Client configuration, you can create your own instance:
{code}
AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");

ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost("http://myProxyHost");
clientConfiguration.setProxyPort(8080);

AmazonS3Client client = new AmazonS3Client(awsCredentials, clientConfiguration);
{code}

and refer to it in your Camel aws-s3 component configuration:
{code}
from("aws-s3://MyBucket?amazonS3Client=#amazonS3Client&delay=5000&maxMessagesPerPoll=5")
.to("mock:result");
{code}

h3. Dependencies
Maven users will need to add the following dependency to their pom.xml.
{code:xml|title=pom.xml}
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-aws</artifactId>
    <version>${camel-version}</version>
</dependency>
{code}

where {{$\{camel-version\}}} must be replaced by the actual version of Camel (2.8 or higher).

{include:Endpoint See Also}
- [AWS Component|AWS]