title: Rails: on-the-fly streaming of output in zip format?
body: <p>I need to serve some data from my database in a zip file, streaming it on the fly such that:</p>
  
  <ul>
  <li>I do not write a temporary file to disk</li>
  <li>I do not compose the whole file in RAM</li>
  </ul>
  
  <p>I know that I can do streaming generation of zip files to the filesystemk using <code>ZipOutputStream</code> as <a href="http://blog.devinterface.com/2010/02/create-zip-files-on-the-fly/" rel="nofollow noreferrer">here</a>.  I also know that I can do streaming output from a rails controller by setting <code>response_body</code> to a <code>Proc</code> as <a href="https://stackoverflow.com/questions/3507594/ruby-on-rails-3-streaming-data-through-rails-to-client">here</a>.  What I need (I think) is a way of plugging those two things together.  Can I make rails serve a response from a <code>ZipOutputStream</code>?  Can I get <code>ZipOutputStream</code> give me incremental chunks of data that I can feed into my <code>response_body</code> <code>Proc</code>?  Or is there another way?</p>