问题描述
我有一个使用apache骆驼的休息api.当我在路线上遇到发帖请求时,它应该从S3获取文件.我正在发送json数据(文件名,bucketName,accesskey,secretkey,region),以便从s3中提取文件.这是该代码->
I have a rest api using apache camel. When I hit a post request on a route, it should get a file from S3. I am sending json data(filename, bucketName, accesskey, secretkey, region) in order to extract the file from s3. Here is the code for that ->
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®ion=INSERT&operation=getObject")
.to("file:/tmp/")
问题是我不希望.setHeader(AWS2S3Constants.KEY, constant("filename"))
部分.有没有一种方法可以删除它,并在URI本身中添加一个替代方法.我尝试过这样的事情->
The issue is that I don't want the .setHeader(AWS2S3Constants.KEY, constant("filename"))
part. Is there a way to remove that and put an alternate to that in the URI itself. I tried something like this ->
public static class HelloRoute extends RouteBuilder {
@Override
public void configure() {
rest("/")
.post("file-from-s3")
.route()
.to("aws2-s3://bucketnameaccessKey=INSERT&secretKey=INSERT®ion=INSERT&filename=hello.txt&operation=getObject")
.to("file:/tmp/")
但这给我一个错误java.lang.IllegalArgumentException: AWS S3 Key header missing.
.还有其他方法吗?
But this is giving me an error java.lang.IllegalArgumentException: AWS S3 Key header missing.
. Is there some other way to do this?
推荐答案
看看: https://camel. apache.org/components/latest/aws2-s3-component.html#_using_a_pojo_as_body
这篇关于仅在URI中设置AWS S3 Key标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!