Search code examples
apache-nifi

UpdateAttribute and PutFile - filename gets a single-quote?


I am working through a Nifi process group that generates a flowfile. I am trying to update the filename attribute, but I notice a single quote gets added to the file too.

UpdateAttribute

In there, you see #{snmp.hostname}-${now()}.json

This does work, but when I look at the output I see:

ls of output

I don't see the quotes when I keep the flowfile filename as is. Here is my PutFile settings, pretty much the default:

PutFile Settings

Here is what is looks like when I don't update attribute, you see the file: 6fd0fcec-c838-4938-a600-5dbe99c4a370 (I do notice a leading space in that flowfile name too?).

enter image description here

Running NiFi 1.16.0 on a RHEL 8.5 machine.


Solution

  • Okay I found the problem. The problem was the date format in now() contained spaces. It seems NiFi will inject a quote around the file name if there are spaces. Replacing ${now()} with ${now():format("yyyy-MM-dd_HH:mm:ss.SSS'Z'", "America/Los_Angeles")} gets rid of the spaces and leads to:

    Screen shot of it working

    And that solves the problem.