I am struggling to build a Groovy scri[t I can run from a NiFi
ExecuteScript processor to extract from a zip file and stream to a tar
archive.

I tried to tackle it all at once and made little progress.
I am now just trying to read the zip file, and am getting this error:

ExecuteScript[id=ae3e5de5-018d-1000-ff81-b0c807b75086] Error occurred
processing FlowFile:
org.apache.nifi.processor.exception.ProcessException: IOException
thrown from ExecuteScript[id=ae3e5de5-018d-1000-ff81-b0c807b75086]:
java.util.zip.ZipException: invalid compression method
- Caused by: java.util.zip.ZipException: invalid compression method


This is my simplified code:


import java.util.zip.ZipInputStream

def ff = session.get()
if (!ff) return

try {
    ff = session.write(ff, { inputStream, outputStream ->
        def zipInputStream = new ZipInputStream(inputStream)
        def entry = zipInputStream.getNextEntry()
        while (entry != null) {
            entry = zipInputStream.getNextEntry()
        }
    } as StreamCallback)

    session.transfer(ff, REL_SUCCESS)
} catch (Exception e) {
    log.error('Error occurred processing FlowFile', e)
    session.transfer(ff, REL_FAILURE)
}


I am able to list and unzip the file at the linux command line, but
cannot get it to work from the script.


Has anyone had success doing this? Can anyone help me get past this error?


Thanks in advance.

Jim

Reply via email to