How to send readStream data as a response without using Buffer


#1

Hi Team,

How to send readStream data as a response without using buffer / Best way to do it. ?


#2
response.implicitEnd = false

response.response.pipe(yourStream)

#3

Getting
Error: Cannot pipe, not readable.!

Helper Function

     async extractFileFromZip(zipFilePath, extractingfile) {
           return new Promise((resolve, reject) => {
             yauzl.open(zipFilePath, { lazyEntries: true }, function (err, zipfile) {
                if (err) {
                    reject(err)
                }

                zipfile.on("entry", function (entry) {
                    if (entry.fileName === extractingfile) {
                        // file entry
                        zipfile.openReadStream(entry, function (err, readStream) {
                            if (err) {
                                reject(err)
                            }
                            resolve(readStream)
                        })
                    }
                    zipfile.readEntry()
                })
                zipfile.readEntry()
            })
        })
    }




{ 
   readStream = await Helpers.extractFileFromZip(FilePath, ext)
   response.implicitEnd = false
   response.response.pipe(readStream)
}

Error: Cannot pipe, not readable
at ServerResponse.pipe (_http_outgoing.js:885:22)