Greetings Chris. I have an idea that *may* work for you to get the file
data into a flow file attribute. Word of caution though: I am relatively
new to NiFi, so this may be harder than it needs to be <lol>. If nothing
else, perhaps it will give you some food for thought.

Have you seen this?
http://funnifi.blogspot.com/2016/03/executescript-json-to-json-revisited_14.html
I found this to be a good stepping stone that permits me to use Python
callbacks to do just about anything I need with attributes - build JSON
objects from attributes, add new attributes, modify existing attributes,
etc etc. I *think* I read somewhere that the actual data for a flow file is
stored in a metadata field called DATA. If that turns out to be the case,
you could mimic this Jython script (thank you to Matt Burgess for his blog
and for these helpful examples), access the data from that DATA field, and
save it to whatever attribute value you'd like. I've done similar many
times to extract xml attributes and values from complex xml metadata,
saving that to a flow file attribute that I add. Use an ExecuteScript
processor to execute the Jython script.

Or if it turns out that there is an attribute metadata field entitled DATA,
perhaps you can just use that?

I hope this helps a little. I hope that I did not misunderstand your
question.
Jim



On Wed, Aug 24, 2016 at 4:33 PM, McDermott, Chris Kevin (MSDU -
STaTS/StorefrontRemote) <[email protected]> wrote:

> Hi folks,
>
>
>
> I’m looking for some ideas here.  I need to read the content of a small
> local file info a flow file attribute.  I can’t find a processor that does
> this.  Did I miss one that does?
>
>
>
> So without one of these I’ve been trying to do this using a MergeContent
> processor.
>
>
>
> First, I assign a correlation UUID and store it in an attribute
>
>
>
> I split by file down two processing paths.  The left hand path goes
> straight to the MergeContentProcessors.
>
>
>
> In the right hand path I
>
> 1.       Read the content of the local file using FetchFile
>
> 2.       Pull the content of the FlowFile into an attribute using
> EvaluateJSONPath
>
> 3.       Clear the content of the FlowFile using ReplaceText
>
>
>
> Then I combine the left and right legs using MergeContent using the
> assigned correlation UUID to merge the files.
>
>
>
> This generally works, except when it doesn’t. J
>
>
>
> The problem seems to be that the left hand side of the stream flows
> relatively faster than the right hand path, which makes sense.  This can
> lead to the “bins” in the MergeContent processor being reused before the
> file in the bin can be merged with the file traveling down the right hand
> path causing Uncorrelated files are then sent to the merged output.
>
>
>
> Does it sound like I am using the MergeContent processor in the right way?
>
>
>
> Any other ideas?
>
>
>
>
>
> Thanks in advance,
>
>
>
> Chris McDermott
>
>
>
> Remote Business Analytics
>
> STaTS/StoreFront Remote
>
> HPE Storage
>
> Hewlett Packard Enterprise
>
> Mobile: +1 978-697-5315
>
>
>
>

Reply via email to