5

As per https://camel.apache.org/file2.html, file component cannot be configured with dynamic input/output folder locations?

Is there any workaround/alternative for the same?

Thanks.

Regards Senthil Kumar Sekar

2 Answers2

3

For the file consumer

You can use a customer filter as dynamic selection of which directories/files to pickup. But the starting directory is configured once (hardcoded).

For that to change you would need to stop the route, and change the directory, and start the route again - if you want to attempt that direction.

For the file producer

The file name is fully dynamic you can just set a name as the file header you want. See documentation for details.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • 1
    OP wanted a dynamic output *folder* location; only the `fileName` portion of a file endpoint can be dynamic AFAICT. – pimlottc Jan 13 '15 at 00:21
  • Beware that if you build dynamic URIs with the CAMEL FTP/SFTP/FTPS component (v2.16.3, likely other versions) you MUST ensure that all variable parts of the URI are passed as Header properties and not URI options; your URI must be the exactly same (ok with ${} props) with every sending. Indeed, a Dynamic Endpoint is recorded in the Cache for every transmission and if the URI differs by a single char, a new object is allocated. This bug https://issues.apache.org/jira/browse/CAMEL-10281 will explode your heap, the documented cache limit (default 1000) is not enforced. – Bernard Hauzeur Sep 05 '16 at 15:18
  • I wish the comment @berhauz made was in the docs... – Snekse Nov 17 '22 at 17:48
1

You can use the header CamelFileName also to dynamically set a directory. Slashes will be turned into directories.

Example: CamelFileName = "directory/dyn_subdirectory_n/myfilename.txt" will be placed into the directory "dyn_subdirectory_n" located in "directory". The filename will be "myfilename.txt".

Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62
moritz.vieli
  • 1,747
  • 1
  • 14
  • 17