Claus Ibsen created CAMEL-25936:
-----------------------------------

             Summary: camel-aws2-s3 - headBucket and headObject take the bucket 
and the key only from headers, not from the endpoint and the keyName option
                 Key: CAMEL-25936
                 URL: https://issues.apache.org/jira/browse/CAMEL-25936
             Project: Camel
          Issue Type: Bug
          Components: camel-aws2-s3
    Affects Versions: 4.18.0, 4.22.0, 4.23.0
            Reporter: Claus Ibsen
             Fix For: 4.24.0


The other operations of the aws2-s3 producer take the bucket from the endpoint 
(or the {{CamelAwsS3OverrideBucketName}} header) and the key from the 
{{keyName}} option (or the {{CamelAwsS3Key}} header), through 
{{AWS2S3Utils.determineBucketName}} and {{determineKey}}. headBucket and 
headObject, added in CAMEL-21262 (4.9.0), read only the headers 
({{AWS2S3Producer}}, main 4065a7464c45, lines 873-877 and 893-897):

{code:java}
private void headBucket(S3Client s3Client, Exchange exchange) {
    String bucketName = 
exchange.getIn().getHeader(AWS2S3Constants.OVERRIDE_BUCKET_NAME, String.class);
    if (ObjectHelper.isEmpty(bucketName)) {
        throw new IllegalArgumentException(
                "Head Bucket operation requires to specify a bucket name via 
Header");
    }
...
private void headObject(S3Client s3Client, Exchange exchange) {
    String key = exchange.getIn().getHeader(AWS2S3Constants.KEY, String.class);
    if (ObjectHelper.isEmpty(key)) {
        throw new IllegalArgumentException(
                "Head Object operation requires to specify a bucket name via 
Header");
{code}

So {{aws2-s3:mybucket?operation=headBucket}} fails with "Head Bucket operation 
requires to specify a bucket name via Header", and 
{{aws2-s3:mybucket?operation=headObject&keyName=a.txt}} fails with "Head Object 
operation requires to specify a bucket name via Header", which names the bucket 
while the key is what is missing. With the headers set, both work. Checked on 
4.24.0-SNAPSHOT against LocalStack S3 ({{camel infra run aws s3}}).

*Proposed change*: take the bucket and the key with 
{{AWS2S3Utils.determineBucketName}} and {{determineKey}}, as the other 
operations do, and name the key in the message of headObject.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to