Skip to main content

About FlowFileSourceResult

Class nifiapi.flowfilesource.FlowFileSourceResult

The FlowFileSourceResult class provides an interface for defining relationship, attributes and content of a FlowFile to be created.

Parameters​

NameTypeDescription
relationshipStringName of the relationship the FlowFile should be routed to
attributesDictionary; Default NoneA key-value pairs representing FlowFile attributes
contentsByte Array or String; Default NoneContent of the FlowFile

e.g.:

from nifiapi.flowfilesource import FlowFileSourceResult


return FlowFileSourceResult(
'success',
attributes={},
contents=None
)

If attributes keyword argument is not provided, a standard set of attributes (filename, path and uuid) will be created regardless. Any additional defined attribute will be appended to that list.

If contents is not provided, a FlowFile with no contents will be created.

Defining FlowFile attributes​

The FlowFileSourceResult provides an interface to define FlowFile attributes.

important

Note that all attributes must be represented as strings.

from nifiapi.flowfilesource import (
FlowFileSource,
FlowFileSourceResult,
)
from nifiapi.properties import ProcessContext


class Processor(FlowFileSource):
(...)

def create(self, context: ProcessContext) -> FlowFileSourceResult:
'''
Parameters:
context (ProcessContext)

Returns:
FlowFileSourceResult
'''
return FlowFileSourceResult('success', attributes={
"new_attribute": str(1234)
})

Defining FlowFile content​

You define the content of a FlowFile through the FlowFileSourceResult. Simply pass new value as contents parameter:

important

Note that content must be either Byte Array or String type.

from nifiapi.flowfilesource import (
FlowFileSource,
FlowFileSourceResult,
)
from nifiapi.properties import ProcessContext


class Processor(FlowFileSource):
(...)

def create(self, context: ProcessContext) -> FlowFileSourceResult:
'''
Parameters:
context (ProcessContext)

Returns:
FlowFileSourceResult
'''
return FlowFileSourceResult('success', contents="New content")