NIFI 保存数据流到本地py脚本

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_34233802/article/details/68941855
import json
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
from org.apache.nifi.processor.exception import ProcessException


class PPutfile(StreamCallback):
    def __init__(self):
        pass
    def process(self,inputStream,outputStream):
        text = IOUtils.toString(inputStream,StandardCharsets.UTF_8)
        f.write(text)




flowfile = session.get()

try:
    if (flowfile != None):
        filename = flowfile.getAttribute("filename")
        f = open("E:\\fdata\\t"+filename,'a+')
        flowfile = session.write(flowfile,PPutfile())
        f.close()
    session.transfer(flowfile, REL_SUCCESS)
except:ProcessException

求职呀。。。。。。。。应届生 qq微信:1255745139

猜你喜欢

转载自blog.csdn.net/sinat_34233802/article/details/68941855