This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7e687135085a CAMEL-28037: camel-aws2-s3 - listObjects and listBuckets
can page, and the docs drop two operations that do not exist (#31262)
7e687135085a is described below
commit 7e687135085ad98bb7e6cc29896ab8576631377b
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Dec 3 20:24:00 2026 +0100
CAMEL-28037: camel-aws2-s3 - listObjects and listBuckets can page, and the
docs drop two operations that do not exist (#31262)
* CAMEL-28037: camel-aws2-s3 - listObjects and listBuckets can page, and
the docs drop two operations that do not exist
* CAMEL-28037: camel-aws2-s3 - listBuckets paging test, the two page caps,
a compiling doc example and the shared-header note
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
---
.../apache/camel/catalog/components/aws2-s3.json | 37 +++---
.../catalog/docs/aws2-s3-producer-operations.adoc | 41 +++++-
.../apache/camel/component/aws2/s3/aws2-s3.json | 37 +++---
.../src/main/docs/aws2-s3-producer-operations.adoc | 41 +++++-
.../camel/component/aws2/s3/AWS2S3Constants.java | 17 +++
.../camel/component/aws2/s3/AWS2S3Producer.java | 47 ++++++-
.../s3/AWS2S3ProducerHttpResponseCodeTest.java | 3 +-
.../s3/AWS2S3ProducerListBucketsPagingTest.java | 143 +++++++++++++++++++++
.../s3/AWS2S3ProducerListObjectsPagingTest.java | 129 +++++++++++++++++++
.../endpoint/dsl/AWS2S3EndpointBuilderFactory.java | 43 +++++++
10 files changed, 486 insertions(+), 52 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3.json
index 5b0d38352729..87299c783262 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3.json
@@ -128,23 +128,26 @@
"CamelHttpResponseCode": { "index": 35, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "Set by the producer after most operations, and after a
streaming upload: the HTTP status code of the response of S3, as an Integer.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#HTTP_RESPONSE_CODE" },
"CamelAwsS3Prefix": { "index": 36, "kind": "header", "displayName": "",
"group": "common", "label": "", "required": false, "javaType": "",
"deprecated": false, "autowired": false, "secret": false, "description": "The
prefix of the listObjects operation: only the objects whose key begins with it
are listed. It replaces the prefix option.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#PREFIX" },
"CamelAwsS3Delimiter": { "index": 37, "kind": "header", "displayName": "",
"group": "common", "label": "", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
delimiter of the listObjects operation, which replaces the delimiter option:
the keys that contain it after the prefix are grouped into common prefixes and
not listed as objects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#DELIMITER" },
- "CamelAwsS3IfMatchCondition": { "index": 38, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is the one of this header; otherwise S3 answers
with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IF_MA [...]
- "CamelAwsS3IfModifiedSinceCondition": { "index": 39, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was modified after this time, a java.time.Instant; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "consta [...]
- "CamelAwsS3IfNoneMatchCondition": { "index": 40, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is not the one of this header; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "constantNam [...]
- "CamelAwsS3IfUnmodifiedSinceCondition": { "index": 41, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was not modified after this time, a java.time.Instant; otherwise S3
answers with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AW [...]
- "CamelAwsS3OverrideBucketName": { "index": 42, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket that the producer operation uses, instead of the
bucket of the endpoint. The producer uses the value of the header as it is:
Simple expressions are only evaluated in the bucket of the endpoint. Not used
in streaming upload mode.", "constantName": [...]
- "CamelAwsS3KeysToDelete": { "index": 43, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"List<String>", "deprecated": false, "autowired": false, "secret": false,
"description": "The keys of the objects that the deleteObjects operation
deletes. Required by deleteObjects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#KEYS_TO_DELETE" },
- "CamelAwsS3RestoreDays": { "index": 44, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The number of days that the copy of the object that the
restoreObject operation restores stays available. The default is 1.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_DAYS" },
- "CamelAwsS3RestoreTier": { "index": 45, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The retrieval tier of the restoreObject operation: Standard
(the default), Bulk or Expedited.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_TIER" },
- "CamelAwsS3ObjectTags": { "index": 46, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putObjectTagging operation sets on the object, replacing its tags. Required by
putObjectTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#OBJECT_TAGS" },
- "CamelAwsS3BucketTags": { "index": 47, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putBucketTagging operation sets on the bucket, replacing its tags. Required by
putBucketTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_TAGS" },
- "CamelAwsS3BucketPolicy": { "index": 48, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket policy, as JSON, that the putBucketPolicy operation
sets. Required by putBucketPolicy.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_POLICY" },
- "CamelAwsS3VersioningStatus": { "index": 49, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The versioning status that the putBucketVersioning operation
sets: Enabled or Suspended. Required by putBucketVersioning.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#VERSIONING_STATUS" },
- "CamelAwsS3MfaDelete": { "index": 50, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The MFA delete status that the putBucketVersioning operation
sets: Enabled or Disabled.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#MFA_DELETE" },
- "CamelAwsS3UploadLinkExpirationTime": { "index": 51, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Long", "deprecated": false, "autowired": false, "secret": false,
"description": "How long the link of the createUploadLink operation is valid,
in milliseconds. The default is one hour. A presigned URL is valid for at most
7 days.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_EXPIRATION_TIME"
},
- "CamelAwsS3UploadLinkBrowserCompatible": { "index": 52, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether the link of the createUploadLink operation works
from a browser, without other headers or payload than the URL. Set by
createUploadLink.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_BROWSER_CO [...]
- "CamelAwsS3UploadLinkHttpRequestHeaders": { "index": 53, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Map<String, List<String>>", "deprecated": false, "autowired":
false, "secret": false, "description": "The HTTP headers that a request to the
link of createUploadLink must send, set when the link is not browser
compatible.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_HTTP_REQUEST_HEA
[...]
- "CamelAwsS3UploadLinkSignedPayload": { "index": 54, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The payload that a request to the link of createUploadLink must
send, set when the link is not browser compatible and has a signed payload.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_SIGNED_PAYLOAD"
}
+ "CamelAwsS3ContinuationToken": { "index": 38, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The continuation token of the listObjects and listBuckets
operations. Set it to list the page that follows the one a previous call
returned. The producer sets it after the operation to the token of the next
page, and removes it when the page is the [...]
+ "CamelAwsS3MaxKeys": { "index": 39, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The maximum number of objects that one listObjects call
returns, or of buckets that one listBuckets call returns. Amazon S3 caps it at
1000 for listObjects and at 10000 for listBuckets, and both caps are also the
defaults.", "constantName": "org.apache.came [...]
+ "CamelAwsS3IsTruncated": { "index": 40, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Boolean", "deprecated": false, "autowired": false, "secret": false,
"description": "Whether the listObjects or listBuckets answer was truncated, so
that more pages follow. The producer sets it after the operation.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IS_TRUNCATED" },
+ "CamelAwsS3IfMatchCondition": { "index": 41, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is the one of this header; otherwise S3 answers
with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IF_MA [...]
+ "CamelAwsS3IfModifiedSinceCondition": { "index": 42, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was modified after this time, a java.time.Instant; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "consta [...]
+ "CamelAwsS3IfNoneMatchCondition": { "index": 43, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is not the one of this header; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "constantNam [...]
+ "CamelAwsS3IfUnmodifiedSinceCondition": { "index": 44, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was not modified after this time, a java.time.Instant; otherwise S3
answers with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AW [...]
+ "CamelAwsS3OverrideBucketName": { "index": 45, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket that the producer operation uses, instead of the
bucket of the endpoint. The producer uses the value of the header as it is:
Simple expressions are only evaluated in the bucket of the endpoint. Not used
in streaming upload mode.", "constantName": [...]
+ "CamelAwsS3KeysToDelete": { "index": 46, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"List<String>", "deprecated": false, "autowired": false, "secret": false,
"description": "The keys of the objects that the deleteObjects operation
deletes. Required by deleteObjects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#KEYS_TO_DELETE" },
+ "CamelAwsS3RestoreDays": { "index": 47, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The number of days that the copy of the object that the
restoreObject operation restores stays available. The default is 1.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_DAYS" },
+ "CamelAwsS3RestoreTier": { "index": 48, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The retrieval tier of the restoreObject operation: Standard
(the default), Bulk or Expedited.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_TIER" },
+ "CamelAwsS3ObjectTags": { "index": 49, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putObjectTagging operation sets on the object, replacing its tags. Required by
putObjectTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#OBJECT_TAGS" },
+ "CamelAwsS3BucketTags": { "index": 50, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putBucketTagging operation sets on the bucket, replacing its tags. Required by
putBucketTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_TAGS" },
+ "CamelAwsS3BucketPolicy": { "index": 51, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket policy, as JSON, that the putBucketPolicy operation
sets. Required by putBucketPolicy.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_POLICY" },
+ "CamelAwsS3VersioningStatus": { "index": 52, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The versioning status that the putBucketVersioning operation
sets: Enabled or Suspended. Required by putBucketVersioning.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#VERSIONING_STATUS" },
+ "CamelAwsS3MfaDelete": { "index": 53, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The MFA delete status that the putBucketVersioning operation
sets: Enabled or Disabled.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#MFA_DELETE" },
+ "CamelAwsS3UploadLinkExpirationTime": { "index": 54, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Long", "deprecated": false, "autowired": false, "secret": false,
"description": "How long the link of the createUploadLink operation is valid,
in milliseconds. The default is one hour. A presigned URL is valid for at most
7 days.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_EXPIRATION_TIME"
},
+ "CamelAwsS3UploadLinkBrowserCompatible": { "index": 55, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether the link of the createUploadLink operation works
from a browser, without other headers or payload than the URL. Set by
createUploadLink.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_BROWSER_CO [...]
+ "CamelAwsS3UploadLinkHttpRequestHeaders": { "index": 56, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Map<String, List<String>>", "deprecated": false, "autowired":
false, "secret": false, "description": "The HTTP headers that a request to the
link of createUploadLink must send, set when the link is not browser
compatible.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_HTTP_REQUEST_HEA
[...]
+ "CamelAwsS3UploadLinkSignedPayload": { "index": 57, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The payload that a request to the link of createUploadLink must
send, set when the link is not browser compatible and has a signed payload.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_SIGNED_PAYLOAD"
}
},
"bodyTypes": {
"consumerOut": { "carriers": [ "bytes" ], "javaType": "byte[]",
"byOption": [ { "option": "includeBody", "value": "false", "carriers": [
"stream" ] }, { "option": "ignoreBody", "value": "true", "carriers": [ "null" ]
} ], "description": "The content of the object as a byte array, one message per
object, with its key and metadata in headers. With includeBody=false the stream
of the object, and with ignoreBody=true no body" },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-producer-operations.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-producer-operations.adoc
index 7a4baa13bef2..13dc3c7d2e1d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-producer-operations.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-producer-operations.adoc
@@ -67,7 +67,7 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| `listBuckets`
| List all buckets for this account in this region.
-|
+| Paged, see <<listPaging>>
| `createBucket`
| Create a new bucket.
@@ -83,7 +83,7 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| `listObjects`
| List objects in a bucket.
-|
+| Paged, see <<listPaging>>
| `getObject`
| Get a single object. Returns its content as a stream.
@@ -109,12 +109,13 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| Retrieve metadata from an object without returning the object itself.
| Requires a key (the `keyName` option or the `CamelAwsS3Key` header)
-| `uploadObject` (default)
-| Upload a file to S3 based on the body content.
+| _(no operation)_
+| Upload the body to S3. This is what the producer does when neither the
`operation` option nor the
+`CamelAwsS3Operation` header is set; there is no operation name for it.
| See <<uploadObject>>
-| `multipartUpload`
-| Upload a large file using multipart upload.
+| _(no operation, with `multiPartUpload=true`)_
+| Upload the body in parts. `multiPartUpload` is an endpoint option, not an
operation.
| See <<multipartUpload>>
| `createDownloadLink`
@@ -186,6 +187,34 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
This section covers operations that require special configuration beyond the
common pattern.
+[[listPaging]]
+=== Paging listObjects and listBuckets
+
+Amazon S3 answers `listObjects` and `listBuckets` one page at a time:
`listObjects` returns at most 1,000 objects per
+page, `listBuckets` at most 10,000 buckets, and both default to that maximum.
Set `CamelAwsS3MaxKeys` to ask for a
+smaller page. When more entries follow, the producer sets
`CamelAwsS3IsTruncated` to `true` and
+`CamelAwsS3ContinuationToken` to the token of the next page; send that token
back in `CamelAwsS3ContinuationToken` to
+read on. On the last page the producer sets `CamelAwsS3IsTruncated` to `false`
and **removes**
+`CamelAwsS3ContinuationToken`, so a route that loops while the header is
present stops by itself.
+
+[source,java]
+----
+from("direct:listAll")
+
.loopDoWhile(PredicateBuilder.or(header("CamelAwsS3ContinuationToken").isNotNull(),
+ exchangeProperty("firstPass").isNull()))
+ .setProperty("firstPass", constant(false))
+ .to("aws2-s3://mybucket?operation=listObjects")
+ .log("got ${body.size()} objects, more:
${header.CamelAwsS3IsTruncated}")
+ .end();
+----
+
+The two operations share the headers. A token of one operation is not valid
for the other, so remove
+`CamelAwsS3ContinuationToken` and `CamelAwsS3MaxKeys` before another list
call, for example between a `listBuckets`
+page and the `listObjects` call made for each of its buckets; otherwise S3
rejects the request.
+
+In POJO mode the token is read from the `ListObjectsV2Request` body, and the
producer still sets the two headers on
+the answer.
+
[[uploadObject]]
=== Upload (Single Upload)
diff --git
a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3/aws2-s3.json
b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3/aws2-s3.json
index 5b0d38352729..87299c783262 100644
---
a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3/aws2-s3.json
+++
b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3/aws2-s3.json
@@ -128,23 +128,26 @@
"CamelHttpResponseCode": { "index": 35, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "Set by the producer after most operations, and after a
streaming upload: the HTTP status code of the response of S3, as an Integer.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#HTTP_RESPONSE_CODE" },
"CamelAwsS3Prefix": { "index": 36, "kind": "header", "displayName": "",
"group": "common", "label": "", "required": false, "javaType": "",
"deprecated": false, "autowired": false, "secret": false, "description": "The
prefix of the listObjects operation: only the objects whose key begins with it
are listed. It replaces the prefix option.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#PREFIX" },
"CamelAwsS3Delimiter": { "index": 37, "kind": "header", "displayName": "",
"group": "common", "label": "", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
delimiter of the listObjects operation, which replaces the delimiter option:
the keys that contain it after the prefix are grouped into common prefixes and
not listed as objects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#DELIMITER" },
- "CamelAwsS3IfMatchCondition": { "index": 38, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is the one of this header; otherwise S3 answers
with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IF_MA [...]
- "CamelAwsS3IfModifiedSinceCondition": { "index": 39, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was modified after this time, a java.time.Instant; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "consta [...]
- "CamelAwsS3IfNoneMatchCondition": { "index": 40, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is not the one of this header; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "constantNam [...]
- "CamelAwsS3IfUnmodifiedSinceCondition": { "index": 41, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was not modified after this time, a java.time.Instant; otherwise S3
answers with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AW [...]
- "CamelAwsS3OverrideBucketName": { "index": 42, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket that the producer operation uses, instead of the
bucket of the endpoint. The producer uses the value of the header as it is:
Simple expressions are only evaluated in the bucket of the endpoint. Not used
in streaming upload mode.", "constantName": [...]
- "CamelAwsS3KeysToDelete": { "index": 43, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"List<String>", "deprecated": false, "autowired": false, "secret": false,
"description": "The keys of the objects that the deleteObjects operation
deletes. Required by deleteObjects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#KEYS_TO_DELETE" },
- "CamelAwsS3RestoreDays": { "index": 44, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The number of days that the copy of the object that the
restoreObject operation restores stays available. The default is 1.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_DAYS" },
- "CamelAwsS3RestoreTier": { "index": 45, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The retrieval tier of the restoreObject operation: Standard
(the default), Bulk or Expedited.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_TIER" },
- "CamelAwsS3ObjectTags": { "index": 46, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putObjectTagging operation sets on the object, replacing its tags. Required by
putObjectTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#OBJECT_TAGS" },
- "CamelAwsS3BucketTags": { "index": 47, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putBucketTagging operation sets on the bucket, replacing its tags. Required by
putBucketTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_TAGS" },
- "CamelAwsS3BucketPolicy": { "index": 48, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket policy, as JSON, that the putBucketPolicy operation
sets. Required by putBucketPolicy.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_POLICY" },
- "CamelAwsS3VersioningStatus": { "index": 49, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The versioning status that the putBucketVersioning operation
sets: Enabled or Suspended. Required by putBucketVersioning.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#VERSIONING_STATUS" },
- "CamelAwsS3MfaDelete": { "index": 50, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The MFA delete status that the putBucketVersioning operation
sets: Enabled or Disabled.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#MFA_DELETE" },
- "CamelAwsS3UploadLinkExpirationTime": { "index": 51, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Long", "deprecated": false, "autowired": false, "secret": false,
"description": "How long the link of the createUploadLink operation is valid,
in milliseconds. The default is one hour. A presigned URL is valid for at most
7 days.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_EXPIRATION_TIME"
},
- "CamelAwsS3UploadLinkBrowserCompatible": { "index": 52, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether the link of the createUploadLink operation works
from a browser, without other headers or payload than the URL. Set by
createUploadLink.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_BROWSER_CO [...]
- "CamelAwsS3UploadLinkHttpRequestHeaders": { "index": 53, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Map<String, List<String>>", "deprecated": false, "autowired":
false, "secret": false, "description": "The HTTP headers that a request to the
link of createUploadLink must send, set when the link is not browser
compatible.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_HTTP_REQUEST_HEA
[...]
- "CamelAwsS3UploadLinkSignedPayload": { "index": 54, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The payload that a request to the link of createUploadLink must
send, set when the link is not browser compatible and has a signed payload.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_SIGNED_PAYLOAD"
}
+ "CamelAwsS3ContinuationToken": { "index": 38, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The continuation token of the listObjects and listBuckets
operations. Set it to list the page that follows the one a previous call
returned. The producer sets it after the operation to the token of the next
page, and removes it when the page is the [...]
+ "CamelAwsS3MaxKeys": { "index": 39, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The maximum number of objects that one listObjects call
returns, or of buckets that one listBuckets call returns. Amazon S3 caps it at
1000 for listObjects and at 10000 for listBuckets, and both caps are also the
defaults.", "constantName": "org.apache.came [...]
+ "CamelAwsS3IsTruncated": { "index": 40, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Boolean", "deprecated": false, "autowired": false, "secret": false,
"description": "Whether the listObjects or listBuckets answer was truncated, so
that more pages follow. The producer sets it after the operation.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IS_TRUNCATED" },
+ "CamelAwsS3IfMatchCondition": { "index": 41, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is the one of this header; otherwise S3 answers
with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#IF_MA [...]
+ "CamelAwsS3IfModifiedSinceCondition": { "index": 42, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was modified after this time, a java.time.Instant; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "consta [...]
+ "CamelAwsS3IfNoneMatchCondition": { "index": 43, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if its entity tag (ETag) is not the one of this header; otherwise S3
answers with the status 304 (Not Modified) for getObject, and 412 (Precondition
Failed) for copyObject.", "constantNam [...]
+ "CamelAwsS3IfUnmodifiedSinceCondition": { "index": 44, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The getObject and copyObject operations get or copy the object
only if it was not modified after this time, a java.time.Instant; otherwise S3
answers with the status 412 (Precondition Failed).", "constantName":
"org.apache.camel.component.aws2.s3.AW [...]
+ "CamelAwsS3OverrideBucketName": { "index": 45, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket that the producer operation uses, instead of the
bucket of the endpoint. The producer uses the value of the header as it is:
Simple expressions are only evaluated in the bucket of the endpoint. Not used
in streaming upload mode.", "constantName": [...]
+ "CamelAwsS3KeysToDelete": { "index": 46, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"List<String>", "deprecated": false, "autowired": false, "secret": false,
"description": "The keys of the objects that the deleteObjects operation
deletes. Required by deleteObjects.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#KEYS_TO_DELETE" },
+ "CamelAwsS3RestoreDays": { "index": 47, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "The number of days that the copy of the object that the
restoreObject operation restores stays available. The default is 1.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_DAYS" },
+ "CamelAwsS3RestoreTier": { "index": 48, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The retrieval tier of the restoreObject operation: Standard
(the default), Bulk or Expedited.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#RESTORE_TIER" },
+ "CamelAwsS3ObjectTags": { "index": 49, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putObjectTagging operation sets on the object, replacing its tags. Required by
putObjectTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#OBJECT_TAGS" },
+ "CamelAwsS3BucketTags": { "index": 50, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"Map<String, String>", "deprecated": false, "autowired": false, "secret":
false, "description": "The tags, as a map of key and value, that the
putBucketTagging operation sets on the bucket, replacing its tags. Required by
putBucketTagging.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_TAGS" },
+ "CamelAwsS3BucketPolicy": { "index": 51, "kind": "header", "displayName":
"", "group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The bucket policy, as JSON, that the putBucketPolicy operation
sets. Required by putBucketPolicy.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#BUCKET_POLICY" },
+ "CamelAwsS3VersioningStatus": { "index": 52, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The versioning status that the putBucketVersioning operation
sets: Enabled or Suspended. Required by putBucketVersioning.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#VERSIONING_STATUS" },
+ "CamelAwsS3MfaDelete": { "index": 53, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"String", "deprecated": false, "autowired": false, "secret": false,
"description": "The MFA delete status that the putBucketVersioning operation
sets: Enabled or Disabled.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#MFA_DELETE" },
+ "CamelAwsS3UploadLinkExpirationTime": { "index": 54, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Long", "deprecated": false, "autowired": false, "secret": false,
"description": "How long the link of the createUploadLink operation is valid,
in milliseconds. The default is one hour. A presigned URL is valid for at most
7 days.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_EXPIRATION_TIME"
},
+ "CamelAwsS3UploadLinkBrowserCompatible": { "index": 55, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "description": "Whether the link of the createUploadLink operation works
from a browser, without other headers or payload than the URL. Set by
createUploadLink.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_BROWSER_CO [...]
+ "CamelAwsS3UploadLinkHttpRequestHeaders": { "index": 56, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Map<String, List<String>>", "deprecated": false, "autowired":
false, "secret": false, "description": "The HTTP headers that a request to the
link of createUploadLink must send, set when the link is not browser
compatible.", "constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_HTTP_REQUEST_HEA
[...]
+ "CamelAwsS3UploadLinkSignedPayload": { "index": 57, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The payload that a request to the link of createUploadLink must
send, set when the link is not browser compatible and has a signed payload.",
"constantName":
"org.apache.camel.component.aws2.s3.AWS2S3Constants#UPLOAD_LINK_SIGNED_PAYLOAD"
}
},
"bodyTypes": {
"consumerOut": { "carriers": [ "bytes" ], "javaType": "byte[]",
"byOption": [ { "option": "includeBody", "value": "false", "carriers": [
"stream" ] }, { "option": "ignoreBody", "value": "true", "carriers": [ "null" ]
} ], "description": "The content of the object as a byte array, one message per
object, with its key and metadata in headers. With includeBody=false the stream
of the object, and with ignoreBody=true no body" },
diff --git
a/components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc
b/components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc
index 7a4baa13bef2..13dc3c7d2e1d 100644
---
a/components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc
+++
b/components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc
@@ -67,7 +67,7 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| `listBuckets`
| List all buckets for this account in this region.
-|
+| Paged, see <<listPaging>>
| `createBucket`
| Create a new bucket.
@@ -83,7 +83,7 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| `listObjects`
| List objects in a bucket.
-|
+| Paged, see <<listPaging>>
| `getObject`
| Get a single object. Returns its content as a stream.
@@ -109,12 +109,13 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
| Retrieve metadata from an object without returning the object itself.
| Requires a key (the `keyName` option or the `CamelAwsS3Key` header)
-| `uploadObject` (default)
-| Upload a file to S3 based on the body content.
+| _(no operation)_
+| Upload the body to S3. This is what the producer does when neither the
`operation` option nor the
+`CamelAwsS3Operation` header is set; there is no operation name for it.
| See <<uploadObject>>
-| `multipartUpload`
-| Upload a large file using multipart upload.
+| _(no operation, with `multiPartUpload=true`)_
+| Upload the body in parts. `multiPartUpload` is an endpoint option, not an
operation.
| See <<multipartUpload>>
| `createDownloadLink`
@@ -186,6 +187,34 @@ and the key from the `keyName` option, unless the
`CamelAwsS3Key` header is set.
This section covers operations that require special configuration beyond the
common pattern.
+[[listPaging]]
+=== Paging listObjects and listBuckets
+
+Amazon S3 answers `listObjects` and `listBuckets` one page at a time:
`listObjects` returns at most 1,000 objects per
+page, `listBuckets` at most 10,000 buckets, and both default to that maximum.
Set `CamelAwsS3MaxKeys` to ask for a
+smaller page. When more entries follow, the producer sets
`CamelAwsS3IsTruncated` to `true` and
+`CamelAwsS3ContinuationToken` to the token of the next page; send that token
back in `CamelAwsS3ContinuationToken` to
+read on. On the last page the producer sets `CamelAwsS3IsTruncated` to `false`
and **removes**
+`CamelAwsS3ContinuationToken`, so a route that loops while the header is
present stops by itself.
+
+[source,java]
+----
+from("direct:listAll")
+
.loopDoWhile(PredicateBuilder.or(header("CamelAwsS3ContinuationToken").isNotNull(),
+ exchangeProperty("firstPass").isNull()))
+ .setProperty("firstPass", constant(false))
+ .to("aws2-s3://mybucket?operation=listObjects")
+ .log("got ${body.size()} objects, more:
${header.CamelAwsS3IsTruncated}")
+ .end();
+----
+
+The two operations share the headers. A token of one operation is not valid
for the other, so remove
+`CamelAwsS3ContinuationToken` and `CamelAwsS3MaxKeys` before another list
call, for example between a `listBuckets`
+page and the `listObjects` call made for each of its buckets; otherwise S3
rejects the request.
+
+In POJO mode the token is read from the `ListObjectsV2Request` body, and the
producer still sets the two headers on
+the answer.
+
[[uploadObject]]
=== Upload (Single Upload)
diff --git
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Constants.java
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Constants.java
index f16a6ff53086..92c510470302 100644
---
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Constants.java
+++
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Constants.java
@@ -218,6 +218,23 @@ public interface AWS2S3Constants {
+ " contain it after the prefix are grouped into
common prefixes and not listed as objects.",
javaType = "String")
String DELIMITER = "CamelAwsS3Delimiter";
+ @Metadata(label = "producer",
+ description = "The continuation token of the listObjects and
listBuckets operations. Set it to list the page"
+ + " that follows the one a previous call returned.
The producer sets it after the operation to"
+ + " the token of the next page, and removes it
when the page is the last one.",
+ javaType = "String")
+ String CONTINUATION_TOKEN = "CamelAwsS3ContinuationToken";
+ @Metadata(label = "producer",
+ description = "The maximum number of objects that one
listObjects call returns, or of buckets that one"
+ + " listBuckets call returns. Amazon S3 caps it at
1000 for listObjects and at 10000 for"
+ + " listBuckets, and both caps are also the
defaults.",
+ javaType = "Integer")
+ String MAX_KEYS = "CamelAwsS3MaxKeys";
+ @Metadata(label = "producer",
+ description = "Whether the listObjects or listBuckets answer was
truncated, so that more pages follow. The"
+ + " producer sets it after the operation.",
+ javaType = "Boolean")
+ String IS_TRUNCATED = "CamelAwsS3IsTruncated";
@Metadata(description = "The getObject and copyObject operations get or
copy the object only if its entity tag (ETag)"
+ " is the one of this header; otherwise S3
answers with the status 412 (Precondition Failed).",
javaType = "String")
diff --git
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
index ba32212c3d5b..206214ddbd56 100644
---
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
+++
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
@@ -644,13 +644,39 @@ public class AWS2S3Producer extends DefaultProducer {
}
private void listBuckets(S3Client s3Client, Exchange exchange) {
- ListBucketsResponse bucketsList = s3Client.listBuckets();
+ ListBucketsRequest.Builder builder = ListBucketsRequest.builder();
+
+ String continuationToken =
exchange.getIn().getHeader(AWS2S3Constants.CONTINUATION_TOKEN, String.class);
+ if (ObjectHelper.isNotEmpty(continuationToken)) {
+ builder.continuationToken(continuationToken);
+ }
+ Integer maxKeys = exchange.getIn().getHeader(AWS2S3Constants.MAX_KEYS,
Integer.class);
+ if (ObjectHelper.isNotEmpty(maxKeys)) {
+ builder.maxBuckets(maxKeys);
+ }
+
+ ListBucketsResponse bucketsList =
s3Client.listBuckets(builder.build());
Message message = getMessageForResponse(exchange);
message.setBody(bucketsList.buckets());
+ setContinuationToken(message, bucketsList.continuationToken());
populateHttpResponseCode(bucketsList, message);
}
+ /**
+ * Sets the token of the next page on the out message, and removes the
header when the page just listed is the last
+ * one, so that a route that loops on the header stops.
+ */
+ private static void setContinuationToken(Message message, String
nextContinuationToken) {
+ boolean truncated = ObjectHelper.isNotEmpty(nextContinuationToken);
+ if (truncated) {
+ message.setHeader(AWS2S3Constants.CONTINUATION_TOKEN,
nextContinuationToken);
+ } else {
+ message.removeHeader(AWS2S3Constants.CONTINUATION_TOKEN);
+ }
+ message.setHeader(AWS2S3Constants.IS_TRUNCATED, truncated);
+ }
+
private void deleteBucket(S3Client s3Client, Exchange exchange) throws
InvalidPayloadException {
final String bucketName = AWS2S3Utils.determineBucketName(exchange,
getConfiguration());
@@ -798,6 +824,7 @@ public class AWS2S3Producer extends DefaultProducer {
ListObjectsV2Response objectList = s3Client.listObjectsV2(req);
Message message = getMessageForResponse(exchange);
message.setBody(objectList.contents());
+ setContinuationToken(message,
objectList.nextContinuationToken());
populateHttpResponseCode(objectList, message);
} else {
throw new IllegalArgumentException(
@@ -809,16 +836,26 @@ public class AWS2S3Producer extends DefaultProducer {
final String prefix
= exchange.getIn().getHeader(AWS2S3Constants.PREFIX,
getConfiguration().getPrefix(), String.class);
- final ListObjectsV2Request listObjectsRequest =
ListObjectsV2Request
+ final ListObjectsV2Request.Builder builder = ListObjectsV2Request
.builder()
.bucket(bucketName)
.delimiter(delimiter)
- .prefix(prefix)
- .build();
- ListObjectsV2Response objectList =
s3Client.listObjectsV2(listObjectsRequest);
+ .prefix(prefix);
+
+ String continuationToken =
exchange.getIn().getHeader(AWS2S3Constants.CONTINUATION_TOKEN, String.class);
+ if (ObjectHelper.isNotEmpty(continuationToken)) {
+ builder.continuationToken(continuationToken);
+ }
+ Integer maxKeys =
exchange.getIn().getHeader(AWS2S3Constants.MAX_KEYS, Integer.class);
+ if (ObjectHelper.isNotEmpty(maxKeys)) {
+ builder.maxKeys(maxKeys);
+ }
+
+ ListObjectsV2Response objectList =
s3Client.listObjectsV2(builder.build());
Message message = getMessageForResponse(exchange);
message.setBody(objectList.contents());
+ setContinuationToken(message, objectList.nextContinuationToken());
populateHttpResponseCode(objectList, message);
}
}
diff --git
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerHttpResponseCodeTest.java
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerHttpResponseCodeTest.java
index 22b1b37405a9..20d99c879156 100644
---
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerHttpResponseCodeTest.java
+++
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerHttpResponseCodeTest.java
@@ -33,6 +33,7 @@ import
software.amazon.awssdk.services.s3.model.DeleteBucketRequest;
import software.amazon.awssdk.services.s3.model.DeleteBucketResponse;
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
import software.amazon.awssdk.services.s3.model.DeleteObjectResponse;
+import software.amazon.awssdk.services.s3.model.ListBucketsRequest;
import software.amazon.awssdk.services.s3.model.ListBucketsResponse;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
@@ -141,7 +142,7 @@ public class AWS2S3ProducerHttpResponseCodeTest {
@Test
public void listBucketsShouldSetHttpResponseCode() throws Exception {
when(configuration.getOperation()).thenReturn(AWS2S3Operations.listBuckets);
- when(s3Client.listBuckets())
+ when(s3Client.listBuckets(any(ListBucketsRequest.class)))
.thenReturn((ListBucketsResponse) ListBucketsResponse.builder()
.sdkHttpResponse(httpStatus(200))
.build());
diff --git
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListBucketsPagingTest.java
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListBucketsPagingTest.java
new file mode 100644
index 000000000000..34d3faab24c0
--- /dev/null
+++
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListBucketsPagingTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.s3;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import software.amazon.awssdk.http.SdkHttpResponse;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.Bucket;
+import software.amazon.awssdk.services.s3.model.ListBucketsRequest;
+import software.amazon.awssdk.services.s3.model.ListBucketsResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * listBuckets reads the continuation token and the page size from the
headers, passes them to S3 as the continuation
+ * token and maxBuckets of the request, and sets the token of the next page
back on the out message, removing it on the
+ * last page.
+ */
+class AWS2S3ProducerListBucketsPagingTest {
+
+ @Mock
+ private AWS2S3Endpoint endpoint;
+
+ @Mock
+ private AWS2S3Configuration configuration;
+
+ @Mock
+ private S3Client s3Client;
+
+ private AWS2S3Producer producer;
+ private DefaultCamelContext camelContext;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ camelContext = new DefaultCamelContext();
+
+ when(endpoint.getConfiguration()).thenReturn(configuration);
+ when(endpoint.getCamelContext()).thenReturn(camelContext);
+ when(endpoint.getS3Client()).thenReturn(s3Client);
+
when(configuration.getOperation()).thenReturn(AWS2S3Operations.listBuckets);
+
+ producer = new AWS2S3Producer(endpoint);
+ }
+
+ @Test
+ void theTokenAndThePageSizeAreSentAndTheNextTokenComesBack() throws
Exception {
+ when(s3Client.listBuckets(any(ListBucketsRequest.class)))
+ .thenReturn((ListBucketsResponse) ListBucketsResponse.builder()
+ .buckets(Bucket.builder().name("first").build(),
Bucket.builder().name("second").build())
+ .continuationToken("page-2")
+ .sdkHttpResponse(httpStatus(200))
+ .build());
+
+ Exchange exchange = new DefaultExchange(camelContext);
+ exchange.getIn().setHeader(AWS2S3Constants.CONTINUATION_TOKEN,
"page-1");
+ exchange.getIn().setHeader(AWS2S3Constants.MAX_KEYS, 2);
+
+ producer.process(exchange);
+
+ ArgumentCaptor<ListBucketsRequest> request =
ArgumentCaptor.forClass(ListBucketsRequest.class);
+ verify(s3Client).listBuckets(request.capture());
+ assertEquals("page-1", request.getValue().continuationToken());
+ assertEquals(2, request.getValue().maxBuckets());
+
+ assertEquals(2, exchange.getMessage().getBody(List.class).size());
+ assertEquals("page-2",
exchange.getMessage().getHeader(AWS2S3Constants.CONTINUATION_TOKEN));
+ assertEquals(Boolean.TRUE,
exchange.getMessage().getHeader(AWS2S3Constants.IS_TRUNCATED));
+ }
+
+ @Test
+ void theLastPageRemovesTheTokenAndIsNotTruncated() throws Exception {
+ when(s3Client.listBuckets(any(ListBucketsRequest.class)))
+ .thenReturn((ListBucketsResponse) ListBucketsResponse.builder()
+ .buckets(Bucket.builder().name("last").build())
+ .sdkHttpResponse(httpStatus(200))
+ .build());
+
+ Exchange exchange = new DefaultExchange(camelContext);
+ exchange.getIn().setHeader(AWS2S3Constants.CONTINUATION_TOKEN,
"page-2");
+
+ producer.process(exchange);
+
+ ArgumentCaptor<ListBucketsRequest> request =
ArgumentCaptor.forClass(ListBucketsRequest.class);
+ verify(s3Client).listBuckets(request.capture());
+ assertEquals("page-2", request.getValue().continuationToken());
+ assertNull(request.getValue().maxBuckets(), "no page size header, so
none is sent");
+
+
assertNull(exchange.getMessage().getHeader(AWS2S3Constants.CONTINUATION_TOKEN),
+ "the header is removed on the last page, so a route that loops
on it stops");
+ assertEquals(Boolean.FALSE,
exchange.getMessage().getHeader(AWS2S3Constants.IS_TRUNCATED));
+ }
+
+ @Test
+ void withoutTheHeadersNothingIsSentForThePaging() throws Exception {
+ when(s3Client.listBuckets(any(ListBucketsRequest.class)))
+ .thenReturn((ListBucketsResponse) ListBucketsResponse.builder()
+ .buckets(Bucket.builder().name("only").build())
+ .sdkHttpResponse(httpStatus(200))
+ .build());
+
+ Exchange exchange = new DefaultExchange(camelContext);
+
+ producer.process(exchange);
+
+ ArgumentCaptor<ListBucketsRequest> request =
ArgumentCaptor.forClass(ListBucketsRequest.class);
+ verify(s3Client).listBuckets(request.capture());
+ assertNull(request.getValue().continuationToken());
+ assertNull(request.getValue().maxBuckets());
+ assertEquals(Boolean.FALSE,
exchange.getMessage().getHeader(AWS2S3Constants.IS_TRUNCATED));
+ }
+
+ private static SdkHttpResponse httpStatus(int statusCode) {
+ return SdkHttpResponse.builder().statusCode(statusCode).build();
+ }
+}
diff --git
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListObjectsPagingTest.java
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListObjectsPagingTest.java
new file mode 100644
index 000000000000..054a8d2c5010
--- /dev/null
+++
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListObjectsPagingTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.s3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.s3.model.S3Object;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * listObjects reads the continuation token and the maximum number of keys
from the headers, and sets the token of the
+ * next page back on the out message, so that a route can walk a bucket with
more objects than one answer carries.
+ */
+class AWS2S3ProducerListObjectsPagingTest extends CamelTestSupport {
+
+ private FakeS3Server s3;
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ s3 = new FakeS3Server("bkt");
+ s3.start();
+ for (int i = 0; i < 5; i++) {
+ s3.put("object" + i + ".txt", "content" + i);
+ }
+ return super.createCamelContext();
+ }
+
+ @AfterEach
+ void stopServer() {
+ if (s3 != null) {
+ s3.stop();
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("direct:list").to("aws2-s3://bkt?accessKey=xxx&secretKey=yyy®ion=us-east-1&overrideEndpoint=true"
+ +
"&forcePathStyle=true&uriEndpointOverride=" + s3.endpoint()
+ + "&operation=listObjects");
+ }
+ };
+ }
+
+ @Test
+ void aPageIsCappedByTheMaxKeysHeaderAndCarriesTheNextToken() {
+ Exchange exchange = template.request("direct:list", e ->
e.getIn().setHeader(AWS2S3Constants.MAX_KEYS, 2));
+
+ Message message = exchange.getMessage();
+ @SuppressWarnings("unchecked")
+ List<S3Object> page = message.getBody(List.class);
+ assertEquals(2, page.size());
+ assertEquals("object0.txt", page.get(0).key());
+ assertEquals("object1.txt", page.get(1).key());
+ assertEquals(Boolean.TRUE,
message.getHeader(AWS2S3Constants.IS_TRUNCATED));
+ assertNotNull(message.getHeader(AWS2S3Constants.CONTINUATION_TOKEN,
String.class),
+ "a truncated answer carries the token of the next page");
+ }
+
+ @Test
+ void theWholeBucketIsReadByFollowingTheContinuationToken() {
+ List<String> keys = new ArrayList<>();
+ String token = null;
+
+ do {
+ final String continuationToken = token;
+ Exchange exchange = template.request("direct:list", e -> {
+ e.getIn().setHeader(AWS2S3Constants.MAX_KEYS, 2);
+ if (continuationToken != null) {
+ e.getIn().setHeader(AWS2S3Constants.CONTINUATION_TOKEN,
continuationToken);
+ }
+ });
+ Message message = exchange.getMessage();
+ message.getBody(List.class).forEach(o -> keys.add(((S3Object)
o).key()));
+ token = message.getHeader(AWS2S3Constants.CONTINUATION_TOKEN,
String.class);
+ } while (token != null);
+
+ assertEquals(List.of("object0.txt", "object1.txt", "object2.txt",
"object3.txt", "object4.txt"), keys);
+ }
+
+ @Test
+ void theLastPageDropsTheTokenAndIsNotTruncated() {
+ Exchange exchange = template.request("direct:list", e ->
e.getIn().setHeader(AWS2S3Constants.MAX_KEYS, 10));
+
+ Message message = exchange.getMessage();
+ assertEquals(5, message.getBody(List.class).size());
+ assertEquals(Boolean.FALSE,
message.getHeader(AWS2S3Constants.IS_TRUNCATED));
+ assertNull(message.getHeader(AWS2S3Constants.CONTINUATION_TOKEN),
+ "the header is removed on the last page, so a route that loops
on it stops");
+ }
+
+ @Test
+ void withoutTheHeadersTheWholeBucketIsListedInOneAnswer() {
+ Exchange exchange = template.request("direct:list", e -> {
+ });
+
+ Message message = exchange.getMessage();
+ assertEquals(5, message.getBody(List.class).size());
+ assertFalse(message.getHeader(AWS2S3Constants.IS_TRUNCATED,
Boolean.class));
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3EndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3EndpointBuilderFactory.java
index 0a7166aa25f9..57f0931635be 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3EndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3EndpointBuilderFactory.java
@@ -4810,6 +4810,49 @@ public interface AWS2S3EndpointBuilderFactory {
public String awsS3Delimiter() {
return "CamelAwsS3Delimiter";
}
+ /**
+ * The continuation token of the listObjects and listBuckets
operations.
+ * Set it to list the page that follows the one a previous call
+ * returned. The producer sets it after the operation to the token of
+ * the next page, and removes it when the page is the last one.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsS3ContinuationToken}.
+ */
+ public String awsS3ContinuationToken() {
+ return "CamelAwsS3ContinuationToken";
+ }
+ /**
+ * The maximum number of objects that one listObjects call returns, or
+ * of buckets that one listBuckets call returns. Amazon S3 caps it at
+ * 1000 for listObjects and at 10000 for listBuckets, and both caps are
+ * also the defaults.
+ *
+ * The option is a: {@code Integer} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsS3MaxKeys}.
+ */
+ public String awsS3MaxKeys() {
+ return "CamelAwsS3MaxKeys";
+ }
+ /**
+ * Whether the listObjects or listBuckets answer was truncated, so that
+ * more pages follow. The producer sets it after the operation.
+ *
+ * The option is a: {@code Boolean} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code AwsS3IsTruncated}.
+ */
+ public String awsS3IsTruncated() {
+ return "CamelAwsS3IsTruncated";
+ }
/**
* The getObject and copyObject operations get or copy the object only
* if its entity tag (ETag) is the one of this header; otherwise S3