Adm-zip Invalid or unsupported zip format. No END header found

1.9k Views Asked by At

I get this error 'Invalid or unsupported zip format. No END header found' when i try to unzip files in memory using adm-zip (buffer). I have confirmed that the file i am trying to unzip is a zip file too.

                    ftpConnection.get(newZipFile.name, function (err, stream:NodeJS.ReadableStream) {
                        if (err) {
                            console.log('error: ', err) 
                        }

                        //  unzipping  files
                        let zdata = []
                        let innerFiles: admZip.IZipEntry[] = []
                        stream.on('data', (buffer) => { zdata.push(buffer) }) 
                        stream.on('end', function () {

                            try {
                                let zip = new admZip(Buffer.concat(zdata)) 
                                innerFiles = zip.getEntries() 
                            } catch (e) {
                                console.log('error: ', e)
                                return
                            }
                       }
0

There are 0 best solutions below