Created 05-25-2017 04:16 PM
I am very new to nifi, I have a requirement to pull specific csv files from the SFTP location, when I pass the full file name it works perfectly, but when I try to write in the regular expression and fetch the file dynamically then i am facing problem, I tried the regular expression ${now():format('yyyy')} and changed the file name to just 2017, even then it is not fetching the file. can somebody help me on this
Created 05-25-2017 05:06 PM
So , to get this working..I need to listSFTP?, if yes..how do i pass it as parameter to fetch the files
Created 06-16-2021 05:52 AM
@anoop_u_shet
@Ash1
Let me try to answer both question here since they are related.
1. Can you set multiple java regular expressions in on single ListSFTP processor? No
If you can come up with one single java regex, that can do your filtering, that will work.
2. Can you have one ListSFTP processor connect to two SFTP servers running on two different target servers? No. You would need to have one ListSFTP processor for each target SFTP server.
3. Can I have just one FetchSFTP processor with multiple ListSFTP processors feeding it? Yes ***
The ListSFTP processor is designed to create FlowFile with numerous FlowFile attributes/metadata and no content. That metadata is then used by the FetchSFTP processor to retrieve tat FlowFile's content.
*** If each target SFTP server uses passwords to authenticate, you may need to use different fetchSFTP processors since passwords can not be stored in FlowFile attributes.
Take a look at the ListSFTP [1] processor documentation/usage (available within yoru install directly from UI under help or on Apache NiFi site) and look at the list of Attributes it writes to the NiFi FlowFiles it creates. You'll see below as some of those attributes:
sftp.remote.host
sftp.remote.port
filename
path
In the FetchSFTP [2] processor, these Attributes from the FlowFile should be used to fetch that FlowFile's content using NiFi Expression Language (NEL) [3]. NEL is commonly used through out your dataflow(s). It allows utilize attributes from FlowFiles (among other things) in processors.
For example, your FetchSFTP may look like this:
You'll see 4 places where I used NEL. NEL expressions always start with "${" and end with "}". Above examples are very simple in that they only read the attribute name form the source FlowFile and use the value assigned to that FlowFile Attribute in the processor configuration property.
NOTE: Not all processor properties support NEL. Floating your cursor over the "?" icon in a property will tell you via popup if NEL is supported by that property.
[1] https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.13.2/org.apach...
[3] https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html
If my responses assisted with yoru queries, please take a moment to click "Accept" on all responses that contributed to a solution for you.
Thank you,
Matt
Created on 06-16-2021 08:33 PM - edited 06-16-2021 10:26 PM
Thanks you very much Matt .. this definitely helped a lot .