<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Hexdump Nifi Processor? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121171#M43072</link>
    <description>&lt;P&gt;Hi Matt!&lt;/P&gt;&lt;P&gt;I now understand what you meant by using the executescript processor!&lt;/P&gt;&lt;P&gt;How would I edit this code to allow me to capture more of the hex output? right now I only get the first 4 characters of hex.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2016 08:23:06 GMT</pubDate>
    <dc:creator>johnmteabo</dc:creator>
    <dc:date>2016-10-12T08:23:06Z</dc:date>
    <item>
      <title>Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121169#M43070</link>
      <description>&lt;P&gt;I need a way to get the hexdump of a file using nifi. I have used an executestreamcommand processor already and it work's but uses a lot of processing power to write each file to a file system. Is there a processor that could achieve this? or does anyone have a custom nar I could use to extract the hexdump of a file? Also I only need the first 16 bits of the file.&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 23:40:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121169#M43070</guid>
      <dc:creator>johnmteabo</dc:creator>
      <dc:date>2016-10-08T23:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121170#M43071</link>
      <description>&lt;P&gt;You could use the &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.script.ExecuteScript/index.html"&gt;ExecuteScript&lt;/A&gt; processor if you are comfortable with Groovy, Javascript, Jython, JRuby, or Lua. Here's an example of a Groovy script that I think will do what you're asking:&lt;/P&gt;&lt;PRE&gt;import java.io.DataInputStream
def flowFile = session.get()
if(!flowFile) return
def attr = ''
session.read(flowFile, {inputStream -&amp;gt;
   dis = new DataInputStream(inputStream)
   attr = Integer.toHexString(dis.readUnsignedShort())
} as InputStreamCallback)
flowFile = session.putAttribute(flowFile, 'first16hex', attr)
session.transfer(flowFile, REL_SUCCESS)&lt;/PRE&gt;&lt;P&gt;This maintains the content in the flow file but adds an attribute called 'first16hex' that contains a string representation of the first 16 bits of the incoming flow file content.&lt;/P&gt;&lt;P&gt;Please let me know if I've misunderstood anything here, and I will try to help. I should mention that a full hexdump processor could be helpful, feel free to raise a &lt;A target="_blank" href="https://issues.apache.org/jira/browse/NIFI/"&gt;Jira&lt;/A&gt; for this feature.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 00:40:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121170#M43071</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-10-09T00:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121171#M43072</link>
      <description>&lt;P&gt;Hi Matt!&lt;/P&gt;&lt;P&gt;I now understand what you meant by using the executescript processor!&lt;/P&gt;&lt;P&gt;How would I edit this code to allow me to capture more of the hex output? right now I only get the first 4 characters of hex.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 08:23:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121171#M43072</guid>
      <dc:creator>johnmteabo</dc:creator>
      <dc:date>2016-10-12T08:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121172#M43073</link>
      <description>&lt;PRE&gt;import java.io.DataInputStream
def flowFile = session.get()
if(!flowFile) return
def attr = ''
session.read(flowFile, {inputStream -&amp;gt;
   dis = new DataInputStream(inputStream)
   attr = Long.toHexString(dis.readLong())
   
} as InputStreamCallback)
flowFile = session.putAttribute(flowFile, 'first16hex', attr)
session.transfer(flowFile, REL_SUCCESS)

&lt;/PRE&gt;&lt;P&gt;Hi Matt, I modified the code to use long instead of short and it gets the first 16 hex bits. How would I get the first 36 Hex bits?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 09:41:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121172#M43073</guid>
      <dc:creator>johnmteabo</dc:creator>
      <dc:date>2016-10-12T09:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121173#M43074</link>
      <description>&lt;P&gt;You'd need multiple calls to dis.readXYZ(), call toHexString() on each, then concatenate before storing in the "attr" or whatever value will be the result (going into the first16hex attribute). For 36 Hex characters, it's probably two dis.readLongs() followed by a dis.readUnsignedShort(). &lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 01:31:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121173#M43074</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-10-15T01:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121174#M43075</link>
      <description>&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;I got it to work with some help from a teammate!&lt;/P&gt;&lt;P&gt;See the code below:&lt;/P&gt;&lt;PRE&gt;import java.io.DataInputStream
def flowFile = session.get()
if(!flowFile) return
def attr = ''
session.read(flowFile, {inputStream -&amp;gt;
   dis = new DataInputStream(inputStream)
   attr = Long.toHexString(dis.readLong())
   attr2 = Long.toHexString(dis.readLong())
   
} as InputStreamCallback)
flowFile = session.putAttribute(flowFile, 'first16hex', attr+attr2)
session.transfer(flowFile, REL_SUCCESS)
&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2016 00:40:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121174#M43075</guid>
      <dc:creator>johnmteabo</dc:creator>
      <dc:date>2016-10-20T00:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121175#M43076</link>
      <description>&lt;P&gt;A source of Hex Filetype headers: &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.garykessler.net/library/file_sigs.html" target="_blank"&gt;http://www.garykessler.net/library/file_sigs.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 00:41:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121175#M43076</guid>
      <dc:creator>johnmteabo</dc:creator>
      <dc:date>2016-10-20T00:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121176#M43077</link>
      <description>&lt;P&gt;&lt;A href="http://www.tutorialspoint.com/unix_commands/hexdump.htm" target="_blank"&gt;http://www.tutorialspoint.com/unix_commands/hexdump.htm&lt;/A&gt; could be called from executestreamcommand&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 00:46:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121176#M43077</guid>
      <dc:creator>TimothySpann</dc:creator>
      <dc:date>2016-10-20T00:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hexdump Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121177#M43078</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;I know this is an old post and the original question was only about the first 16 bits hex dump. However, since I came across this post and it gave me some directions, I've tried to improve it considering the following things:&lt;/P&gt;&lt;P&gt;1) In case the flowfile has, say, 93 bytes, using Long or UnsignedShort allows only to shift 8 or 4 bytes at the time, making it impossible to read an odd number of bytes. Thus, I've used readUnsignedByte instead.&lt;/P&gt;&lt;P&gt;2) Missing left padding zeros&lt;/P&gt;&lt;P&gt;3) Reading the whole flowfile and dumping it in an attribute, which I've called 'raw'&lt;/P&gt;&lt;PRE&gt;import java.io.DataInputStream
def flowFile = session.get()
if(!flowFile) return
def raw = ''
def aux = ''
boolean eof = false
session.read(flowFile, {inputStream -&amp;gt;
  dis = new DataInputStream(inputStream)
  while (!eof) {
    try {
       aux = Integer.toHexString(dis.readUnsignedByte());
       raw = raw + aux.padLeft(2,'0');
    } catch (EOFException e) {
        eof = true;
    }
  }
} as InputStreamCallback)
flowFile = session.putAttribute(flowFile, 'raw', raw)
session.transfer(flowFile, REL_SUCCESS)
&lt;/PRE&gt;&lt;P&gt;As I am a newbie, please feel free to comment.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Gus&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 01:12:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hexdump-Nifi-Processor/m-p/121177#M43078</guid>
      <dc:creator>gustavobergamo3</dc:creator>
      <dc:date>2017-05-26T01:12:04Z</dc:date>
    </item>
  </channel>
</rss>

