Russell, session.read() won't overwrite any contents of the incoming flow file, but write() will. For #2, are you doing any processing on the file? If not, wouldn't that be the original flowfile anyway? Or do you want it to be a different flowfile on purpose (so you can send the incoming flowfile to a different relationship)? You can use session.clone() to create a new flowfile that has the same content and attributes from the incoming flowfile, then handle that separately from the incoming (original) flowfile. For #1, you could clone() the original flowfile and do the read/process/write as part of a session.write(FlowFile, StreamCallback) call, then you're technically reading the "new" file content (which is the same of course) and overwriting it on the way out.
Regards, Matt On Mon, Aug 24, 2020 at 6:37 PM Russell Bateman <r...@windofkeltia.com> wrote: > > I am writing a custom processor that, upon processing a flowfile, > results in two new flowfiles (neither keeping the exact, original > content) out two different relationships. I might like to route the > original flowfile to a separate relationship. > > FlowFile original = session.get(); > > Do I need to call session.create()for the two new files? > > 1. session.read()of original file's contents, not all of the way > through, but send the processed output from what I do read as > flowfile 1. > 2. session.read()of original file's contents and send resulting output > as flowfile 2. > 3. session.transfer()of original flowfile. > > I look at all of these session.read()and session.write()calls and I'm a > bit confused as to which to use that won't lose the original flowfile's > content after #1 so I can start over again in #2. > > Thanks.