Search code examples
apache-cameljbossfuse

Downloading a file using camel


I want to download a zip file using apache camel route. For this purpose, I have used following code.

<from uri="timer:testTimer?repeatCount=1"/>
<to uri="http://example.com/data.zip"/>
<to uri="file:data.zip"/>

This code is successfully downloading the source file. However, I find following limitations

  • A directory named data.zip is created, and file is saved inside that directory.
  • File name is something dependent on system(combination of system-id and something else)

So, basically my questions are:

  • Am I using the right way to download the file?
  • How can I ask the file component to use a specific file name for downloaded file, so that I can use that name in some other routes. [UPDATE] In documentation, I just noticed use of fileName attribute to set file name. Will it work in this case?

Solution

  • Yes use file:directoryName?fileName=data.zip to tell Camel to store the file in that directory using that file name.

    Read more in the documents: http://camel.apache.org/file2