I\'m trying to upload a jpg file to AWS S3 bucket with Camel\'s aws-s3 producer. Can I make this work with this approach and if yes how? Now I\'m only getting an IOException and
I did some digging and found one solution. Route works if you convert file contents to byte array before passing it to the aws-s3 endpoint like this:
from("file://src/data?fileName=file.jpg&noop=true&delay=15m")
.convertBodyTo(byte[].class)
.setHeader(S3Constants.CONTENT_LENGTH, simple("${in.header.CamelFileLength}"))
.setHeader(S3Constants.KEY,simple("${in.header.CamelFileNameOnly}"))
.to("aws-s3://{{awsS3BucketName}}"
+ "?deleteAfterWrite=false®ion=eu-west-1"
+ "&accessKey={{awsAccessKey}}"
+ "&secretKey=RAW({{awsAccessKeySecret}})")
.log("done.");
}
There must also be S3Constants.CONTENT_LENGTH header value set to the file length in bytes.
The solution above reads whole file to memory so it's not ideal to every situation. However the code above is also the most simple way that I know of using aws-s3 producer endpoint. I'm still happy to hear about other (and better) solutions.