0

I am new to Apache Camel. I want to access the data sent through a post request in order to download a file from S3. This is the router that I wrote.

public static class HelloRoute extends RouteBuilder {
       
        @Override
        public void configure() {
            rest("/")
                .post("file-from-s3")
                    .route()
                    .setHeader(AWS2S3Constants.KEY, constant("filename"))
                    .to("aws2-s3://bucketnameaccessKey=INSERT&secretKey=INSERT&region=INSERT&operation=getObject")
                    .to("file:/tmp/")
                    .endRest();
        }

The corresponding json data that will be sent ->

{
     "filename" : "test.txt",
     "bucketname": "testbucket",
     "accessKey" : "key",
     "secretKey" : "key2",
     "region"    : "region"

}

How to do I access these json values in the code above?

Adi shukla
  • 173
  • 3
  • 11
  • The request will be framed by the AWS component within the SDK, try enabling debug logs for the AWS component. – Venkat Jul 04 '20 at 16:28

1 Answers1

0

You need to unmarshal the JSON request data first. You can choose from a variety of libs and ways to do this, check out the Camel docs for JSON.

Then the message body contains the structure you unmarshalled your data to (POJO, Map). So you can access it on various ways by using Simple directly in the Route or a Bean method that is called from the route etc.

burki
  • 6,741
  • 1
  • 15
  • 31