title: Stream and zip to S3 from AWS Lambda Node.JS
body: <p>My goal is to create a large gzipped text file and put it into S3.</p>
  
  <p>The file contents consist of blocks which I read in a loop from another source.</p>
  
  <p>Because of the size of this file I can not hold all data in memory, so I need to somehow stream it directly to S3 and ZIP at the same time.</p>
  
  <p>I understand how to perform this trick with the regular <code>fs</code> in Node.JS, but I am confused about whether is it possible to do the same trick with S3 from AWS Lambda? I know that <code>s3.putObject</code> <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property" rel="nofollow noreferrer">can consume</a> <code>streamObject</code>, but it seems to me that this stream should be already finalized when I perform <code>putObject</code> operation, what can cause exceeding of the allowed memory. </p>