S3 Component
Available as of Camel 2.8
The S3 component supports storing and retrieving objetcs from/to Amazon's S3 service.
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.
URI Format
aws-s3://bucketName[?options] aws-s3://bucketNameOrArn[?options] (Camel 2.18 onwards)
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&...
URI Options
Name | Default Value | Context | Description |
---|---|---|---|
amazonS3Client |
| Shared | Reference to a |
accessKey |
| Shared | Amazon AWS Access Key |
secretKey |
| Shared | Amazon AWS Secret Key |
amazonS3Endpoint |
| Shared | The region with which the AWS-S3 client wants to work with. |
region |
| Producer | The region who the bucket is located. This option is used in the |
deleteAfterRead |
| Consumer | Delete objects from S3 after it has been retrieved. |
deleteAfterWrite |
| Producer | Camel 2.11.0 Delete file object after the S3 file has been uploaded |
maxMessagesPerPoll | 10 | Consumer | The maximum number of objects which can be retrieved in one poll. Used in in the |
policy |
| Shared | Camel 2.8.4: The policy for this queue to set in the |
storageClass |
| Producer | Camel 2.8.4: The storage class to set in the |
prefix |
| Consumer | Camel 2.10.1: The prefix which is used in the |
multiPartUpload | false | Producer | Camel 2.15.0: If it is true, camel will upload the file with multi part format, the part size is decided by the option of partSize |
partSize |
| Producer | Camel 2.15.0: Setup the partSize which is used in multi part upload, the default size is 25M. |
serverSideEncryption | null | Producer | Camel 2.16: Sets the server-side encryption algorithm when encrypting the object using AWS-managed keys. For example use AES256. |
proxyHost | null | Producer | Camel 2.16: Specify a proxy host to be used inside the client definition. |
proxyPort | null | Producer | Camel 2.16: Specify a proxy port to be used inside the client definition. |
includeBody | true | Consumer | Camel 2.17: If it is true the exchange body will be set to a stream to the contents of the file. If false the headers will be set with the S3 object metadata but the body will be null. |
operation | null | Producer | Camel 2.18: The operation to perform in case the end-user don't want to do a simple upload. Values can be: copyObject, listBuckets, deleteBucket |
Required S3 component options
You have to provide the amazonS3Client in the Registry or your accessKey and secretKey to access the Amazon's S3.
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.
Usage
Message headers evaluated by the S3 producer
Header | Type | Description |
---|---|---|
|
| The key under which this object will be stored or which will be used for the current operation. |
|
| Camel 2.18: The bucket Name which this object will be stored or which will be used for the current operation |
|
| Camel 2.18: The bucket Destination Name which will be used for the current operation |
|
| The content length of this object. |
|
| The content type of this object. |
|
| Camel 2.8.2: The content control of this object. |
|
| Camel 2.8.2: The content disposition of this object. |
|
| Camel 2.8.2: The content encoding of this object. |
|
| Camel 2.8.2: The md5 checksum of this object. |
|
| Camel 2.18: The Destination key which will be used for the current operation |
|
| Camel 2.8.2: The last modified timestamp of this object. |
|
| Camel 2.18: The operation to perform. Values can be: copyObject, listBuckets, deleteBucket |
|
| Camel 2.8.4: The storage class of this object. |
|
| Camel 2.11.0: The canned acl that will be applied to the object. see |
|
| Camel 2.11.0: a well constructed Amazon S3 Access Control List object. see |
CamelAwsS3Headers | Map<String,String> | Camel 2.15.0: support to get or set custom objectMetadata headers. |
CamelAwsS3ServerSideEncryption | String | Camel 2.16: Sets the server-side encryption algorithm when encrypting the object using AWS-managed keys. For example use AES256. |
Message headers set by the S3 producer
Header | Type | Description |
---|---|---|
|
| The ETag value for the newly uploaded object. |
|
| The optional version ID of the newly uploaded object. |
Message headers set by the S3 consumer
Header | Type | Description |
---|---|---|
|
| The key under which this object is stored. |
|
| The name of the bucket in which this object is contained. |
|
| 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. |
|
| The value of the Last-Modified header, indicating the date and time at which Amazon S3 last recorded a modification to the associated object. |
|
| 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. |
|
| 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. |
|
| 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. |
|
| The Content-Length HTTP header indicating the size of the associated object in bytes. |
|
| 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. |
|
| The optional Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as. |
|
| The optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain. |
CamelAwsS3ServerSideEncryption | String | Camel 2.16: The server-side encryption algorithm when encrypting the object using AWS-managed keys. |
Advanced AmazonS3 configuration
If your Camel Application is running behind a firewall or if you need to have more control over the AmazonS3
instance configuration, you can create your own instance:
AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey"); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProxyHost("http://myProxyHost"); clientConfiguration.setProxyPort(8080); AmazonS3 client = new AmazonS3Client(awsCredentials, clientConfiguration); registry.bind("client", client);
and refer to it in your Camel aws-s3 component configuration:
from("aws-s3://MyBucket?amazonS3Client=#client&delay=5000&maxMessagesPerPoll=5") .to("mock:result");
Dependencies
Maven users will need to add the following dependency to their pom.xml.
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-aws</artifactId> <version>${camel-version}</version> </dependency>
where ${camel-version
} must be replaced by the actual version of Camel (2.8 or higher).