You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by megachucky <me...@googlemail.com> on 2011/08/29 19:11:15 UTC

AWS-Component (S3) => Best way to set the CamelAwsS3Key Header?

Hello.

Again a question about the AWS component (S3). What is the best way to set
the CamelAwsS3Key header?

I did it this way:
from("file:files/inbox").setHeader(S3Constants.KEY, simple("Static
Key")).......

The test in the source code does this:

        Exchange exchange = template.send("direct:start",
ExchangePattern.InOut, new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(S3Constants.KEY,
"CamelUnitTest");
                exchange.getIn().setBody("This is my bucket content.");
            }

If the key is null, then the following is called in the camel aws code:
throw new IllegalArgumentException("AWS S3 Key header missing.");

Thus, I have to set a key (of course it must not be null due to the S3
service!). 
Nevertheless, I also managed to do it automatically: In my first try, the
key was message1.xml and message2.xml -> I did not set a header. The name of
the files was used.

Unfortunately, I cannot reproduce this. Italways get the exception, if  I do
not set the header. Can you please help me out? What is the configuration
that the header is set automatically?

Thank you...

Best regards,
Kai
       

--
View this message in context: http://camel.465427.n5.nabble.com/AWS-Component-S3-Best-way-to-set-the-CamelAwsS3Key-Header-tp4746938p4746938.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: AWS-Component (S3) => Best way to set the CamelAwsS3Key Header?

Posted by Brendan Long <br...@realgo.com>.
It doesn't look like there is an automatic way of setting the S3 key, so
I'm not sure why it worked the first time.

I think what you're trying to do would be this:

Message in = exchange.getIn();
in.setHeader(S3Constants.KEY, in.getHeader(Exchange.FILE_NAME));

On 2011-08-29 11:11 AM, megachucky wrote:
> Hello.
>
> Again a question about the AWS component (S3). What is the best way to set
> the CamelAwsS3Key header?
>
> I did it this way:
> from("file:files/inbox").setHeader(S3Constants.KEY, simple("Static
> Key")).......
>
> The test in the source code does this:
>
>         Exchange exchange = template.send("direct:start",
> ExchangePattern.InOut, new Processor() {
>             public void process(Exchange exchange) throws Exception {
>                 exchange.getIn().setHeader(S3Constants.KEY,
> "CamelUnitTest");
>                 exchange.getIn().setBody("This is my bucket content.");
>             }
>
> If the key is null, then the following is called in the camel aws code:
> throw new IllegalArgumentException("AWS S3 Key header missing.");
>
> Thus, I have to set a key (of course it must not be null due to the S3
> service!). 
> Nevertheless, I also managed to do it automatically: In my first try, the
> key was message1.xml and message2.xml -> I did not set a header. The name of
> the files was used.
>
> Unfortunately, I cannot reproduce this. Italways get the exception, if  I do
> not set the header. Can you please help me out? What is the configuration
> that the header is set automatically?
>
> Thank you...
>
> Best regards,
> Kai
>        
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/AWS-Component-S3-Best-way-to-set-the-CamelAwsS3Key-Header-tp4746938p4746938.html
> Sent from the Camel - Users mailing list archive at Nabble.com.