Skip to main content
HoangNguyen
Silver ⭐️⭐️
August 22, 2025
Solved

How to user attribute in Listfile

Hi Expert,

I've the incoming flowfile have a attribute somethings like cdc = 12. And I'd like to list file in the folder looks like /home/user/cdc=${cdc}.

Because the listfile not required an incomming flowfile. So How can I achieve this?

Thank you so much.

vafs
vafsAnswer
Gold ⭐️⭐️⭐️
August 22, 2025

Hello @HoangNguyen, 

If I do not understand wrong, what you want is not possible. 
ListFile does not support incoming FlowFile as an source. 
To do that, you will need to use variable registry. 
Look here:

Display Name: Input Directory
API Name: Input Directory
Description: The input directory from which files to pull files
Supports Expression Language: true (will be evaluated using variable registry only)
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.2/org.apache.nifi.processors.standard.ListFile/index.html

Looking on that, FetchFile will do what you need: 

Display Name: File to Fetch
API Name: File to Fetch
Default Value: ${absolute.path}/${filename}
Description: The fully-qualified filename of the file to fetch from the file system
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.2/org.apache.nifi.processors.standard.FetchFile/index.html

Regards, Andrés Fallas -- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs-up button.

3 replies

vafs
Gold ⭐️⭐️⭐️
vafsAnswer
Gold ⭐️⭐️⭐️
August 22, 2025

Hello @HoangNguyen, 

If I do not understand wrong, what you want is not possible. 
ListFile does not support incoming FlowFile as an source. 
To do that, you will need to use variable registry. 
Look here:

Display Name: Input Directory
API Name: Input Directory
Description: The input directory from which files to pull files
Supports Expression Language: true (will be evaluated using variable registry only)
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.2/org.apache.nifi.processors.standard.ListFile/index.html

Looking on that, FetchFile will do what you need: 

Display Name: File to Fetch
API Name: File to Fetch
Default Value: ${absolute.path}/${filename}
Description: The fully-qualified filename of the file to fetch from the file system
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.2/org.apache.nifi.processors.standard.FetchFile/index.html

Translate
Regards, Andrés Fallas -- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs-up button.
HoangNguyen
Silver ⭐️⭐️
August 25, 2025

Gracias Andrés, It's really helpful

Translate
MattWho
Titanium ⭐️⭐️⭐️
Titanium ⭐️⭐️⭐️
August 25, 2025

@HoangNguyen 

Keep in mind that the Apache NiFi Variable Registry no longer exist in Apache NiFi 2.x releases and there is no more development of the Apache NIFi 1.x versions.  NiFi Parameter Contexts, which were introduced in later versions of Apache NiFi 1.x, provides similar capability going forward and should be used instead of the variable registry.  You'll be forced to transition to Parameter Contexts in order to move to Apache NiFi 2.x. versions.

 

Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

Translate