Created 09-21-2016 09:54 AM
(I'm still getting familiar w/ NiFi, so this might have a really obvious answer)
I have a flow where I take a text file that contains a per-line list of files. I grab this file with a FetchFile processor, and then feed the output to a SplitText processor, giving me one flow file per row.
So my flow file is literally just a string with a file path "x", like '/home/zack/my_folder/my_file'.
Then, I want to add either a FetchFile processor or a ExecuteStream processor to get the file represented by "x" and copy it to a different folder.
However, I can't figure out how to reference "x".
Is there a way, using the markup language I would guess, to somehow get a handle on that file path string so I can use it?
thanks!
Created 09-21-2016 10:40 AM
You would have to use ExtractText processor to extract the path and set it as an attribute of your flow file. Then you can use this attribute using expression language in the next processors.
Let's say you extract .* to put it as attribute "mypath", then in following processor, for properties accepting expression language, you can reference this value using ${mypath}.
Hope this helps.
Created 09-21-2016 10:40 AM
You would have to use ExtractText processor to extract the path and set it as an attribute of your flow file. Then you can use this attribute using expression language in the next processors.
Let's say you extract .* to put it as attribute "mypath", then in following processor, for properties accepting expression language, you can reference this value using ${mypath}.
Hope this helps.
Created 09-21-2016 08:09 PM
Thanks Pierre,
A quick followup question:
How can I use the markup language to strip the path from a file?
So, in the example above, how do I get 'my_file' from 'home/zack/my_folder/my_file' ?
I'm guessing I use a UpdateAttribute processor... thanks!
Created 09-21-2016 09:07 PM
Yes correct. You could also do both in once with ExtractText processor, but you definitely can use UpdateAttribute and expression language functions to get the result you want. Also if you only need the filename for a processor in a property accepting expression language, you don't need the intermediate step. For example:
${mypath:substringAfterLast('/')}
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html
Hope this helps.