Skip to Content
Technical Articles

Dynamic configuration to setup filename and directory – receiver SFTP

Hello Integration Folks,

This blog post is about setting up dynamic filename and dynamic folder on receiver SFTP for different incoming files.

Business Case: Suppose you have n (in this case 2) different kind of incoming files which you are polling from same SFTP directory path and needs to deposit to different folders on same SFTP server.

Solution Approach:

  1. Create your iflow as required, for this case its something like below.

  1. Set the directory paths for multiple incoming routes using content modifier.

Here, I have set it as 1 and 2 as shown in LIP in main iflow in step1.

1st content modifier: (route 1)

2nd content modifier: (route 2)

Keep the variable name same for all the directories you will set.

Note: I am polling file from SFTP, and routing files based on their filenames. For more info, read my previous blog post.

  1. Use another content modifier in main integration process to set the dynamic filename and dynamic directory path.

Put name as CamelFileName as this is standard camel expression for filename and set its value as   /[root directory path]/${header.path}/${file:onlyname}

In my case root directory is /test/ECC.

file:onlyname refers to the file name only with no leading paths.

There are few other parameters as well, you can follow reference link at the end.

  1. Configure your receiver SFTP and keep file access parameters as blank as it would dynamically take the values from step 3.

Your files will be deposited in different folders based on dynamic configuration setup.

 

Reference Link:

https://camel.apache.org/components/latest/languages/file-language.html

Conclusion: CPI users will now be able to deposit files on multiple directories on same SFTP server based on their filenames.

Please keep supporting and suggest improvements.

Happy learning !!! 🙂

Thanks & regards,

sachin tripathi

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.