title: How to gunzip stream in nodejs?
body: <p>I'm trying to accomplish quite an easy task but I'm a little bit confused and got stuck on using zlib in nodejs. I'm building functionality that includes me downloading file from aws S3 which is gziped, unzipping it and  reading it line by line. I want to accomplish all of this using streams as I believe it is possible to do so in nodejs.</p>
  
  <p>Here is my current code base:</p>
  
  <pre><code>//downloading zipped file from aws s3:
  //params are configured correctly to access my aws s3 bucket and file
  
  s3.getObject(params, function(err, data) {
    if (err) {
      console.log(err);
    } else {
  
      //trying to unzip received stream:
      //data.Body is a buffer from s3
      zlib.gunzip(data.Body, function(err, unzippedStream) {
        if (err) {
          console.log(err);
        } else {
  
          //reading line by line unzziped stream:
          var lineReader = readline.createInterface({
            input: unzippedStream
          });
          lineReader.on('line', function(lines) {
            console.log(lines);
          });
        }
      });
    }
  });
  </code></pre>
  
  <p>I get an error saying:</p>
  
  <pre><code> readline.js:113
  
          input.on('data', ondata);
                ^
  
      TypeError: input.on is not a function
  </code></pre>
  
  <p>I believe a problem might be in unzipping process, but I'm not too sure what is wrong, any help would be appreciated.</p>