Nifi:写入流文件

Nifi : write to flowfile

我正在尝试使用 groovy 写入 Nifi 中的流文件 outputStream(这是一个字节数组输出流)。但是,我写入流文件的大小为零。我做错了吗?提前致谢。

代码: FlowFile newFlowFile = sess.create();

newFlowFile = sess.write(newFlowFile, { out ->
    outputStream
} as OutputStreamCallback)

如果 outputStream 是字节数组输出流,那么您可以使用 ByteArrayOutputStream.writeTo(stream) 方法将字节数组的内容写入其他输出流。

newFlowFile = sess.write(newFlowFile, { out ->
    outputStream.writeTo(out)
} as OutputStreamCallback)