【问题标题】:Set the AWS S3 Key header in the URI only仅在 URI 中设置 AWS S3 Key 标头
【发布时间】:2020-07-01 21:35:41
【问题描述】:

我有一个使用 apache camel 的 rest api。当我在一条路线上发出一个发布请求时,它应该从 S3 获取一个文件。我正在发送 json data(filename, bucketName, accesskey, secretkey, region) 以便从 s3 中提取文件。这是那个的代码 ->

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/")
               

问题是我不想要.setHeader(AWS2S3Constants.KEY, constant("filename")) 部分。有没有办法删除它并在 URI 本身中放置一个替代项。我试过这样的东西->

public static class HelloRoute extends RouteBuilder {
       
        @Override
        public void configure() {
            rest("/")
                .post("file-from-s3")
                    .route()                 
                    .to("aws2-s3://bucketnameaccessKey=INSERT&secretKey=INSERT&region=INSERT&filename=hello.txt&operation=getObject")
                    .to("file:/tmp/")
               

但这给了我一个错误java.lang.IllegalArgumentException: AWS S3 Key header missing.。有没有其他方法可以做到这一点?

【问题讨论】:

  • @KavithakaranKanapathippillai Unknown parameters=[{camel.component.aws2-s3.key-name=hello.txt}] 将此视为错误

标签: amazon-web-services amazon-s3 apache-camel


【解决方案1】:

有时构建 AWS 请求可能很复杂,因为有多个选项。我们介绍了使用 POJO 作为主体的可能性。

看看:https://camel.apache.org/components/latest/aws2-s3-component.html#_using_a_pojo_as_body

【讨论】:

猜你喜欢
  • 2016-12-21
  • 2017-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-12
  • 2010-12-08
  • 2016-07-21
  • 2014-09-29
相关资源
最近更新 更多