2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Apache Camelを通じて、Boxからファイルのダウンロード

Last updated at Posted at 2020-12-09

pom.xmlに依頼の導入:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-box</artifactId>
    <version>${camel-version}</version>
</dependency>

使い方(例):
ルートの書き方:

...
String fileId=...;
String fileName=...;
...
from("direct:foo")
    .setHeader("CamelBox.fileId", constant(fileId))
    .setHeader("CamelBox.output", constant(output))
    .to("box://files/download")
    .to("file://...");

注意点:
ダウンロードのBoxファイルのリンクと目的のローカルのリンクは".to()"の中に書く。

ルートの使用:
.to("direct:foo")で呼び出すことが可能ですが、
別のルートを使わない場合:

try{
   template.sendBody("direct:foo", "This is a test message,please download the file");
}catch(CamelExecutionException e){
     System.out.println(e);
}

"direct"はcamelの二つコンポネートの間に連携用のコンポネートです。
"direct:foo"について、"foo"をほかの自分で定義する名でも可能です。

Camel Box:
https://camel.apache.org/components/latest/box-component.html
Camel direct:
https://camel.apache.org/components/latest/direct-component.html

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?