Search code examples
amazon-web-servicesamazon-s3apache-camel

Apache camel, upload a files to folder in the S3 bucket


I am trying to upload the files to a folder under the s3 bucket but I am getting the error as below :

Please help.

Thanks in advance, Pradeep

Caused by: software.amazon.awssdk.services.s3.model.S3Exception: null (Service: S3, Status Code: 403, Request ID: xxxxxxxx, Extended Request ID: xxxxxxxxx)

my code upload the files as follows :

 String awsRegion = "eu-west-1";
 String bucketName = "webdavs3bucket/myfolder";
 String s3Endpoint = "aws2-s3://" + bucketName + "?region=" + awsRegion + "&useDefaultCredentialsProvider=true";


from("file:{{base.working.dir}}")
                .log("Uploading file latest changes====>: ${header.CamelFileName}")
                .log(s3Endpoint)
                .setHeader(AWS2S3Constants.KEY, simple("${file:name}"))
                .toD(s3Endpoint)
                .log("File uploaded successfully to S3");

Solution

  • I got the issue, it is because of the policy which was restricting the user to upload files