title: Best Practices to Create and Download a huge ZIP (from several BLOBs) in a WebApp
body: <p>I will need to perform a massive download of files from my Web Application.</p>
  
  <p>It is obviously expected to be a long-running action (it'll be used <em>once-per-year[-per-customer]</em>), so the time is not a problem (unless it hits some timeout, but I can handle that by creating some form of keepalive heartbeating). I know how to create an hidden <em>iframe</em> and use it with <code>content-disposition: attachment</code> to attempt to download the file instead of opening it inside the browser, and how to instance a client-server communication for drawing a progress meter;</p>
  
  <p>The actual size of the download (and the number of files) is unknown, but for simplicity we can virtually consider it as 1GB, composed of 100 files, each 10MB.</p>
  
  <p>Since this should be a one-click operation, my first thought was to group all the files, while reading them from the database, in a dynamically generated ZIP, then ask the user to save the ZIP.</p>
  
  <p>The question is: <strong>what are the best practices, and what are the known drawbacks and traps, in creating a huge archive from multiple small byte arrays in a WebApp?</strong> </p>
  
  <p>That can be randomly split into: </p>
  
  <ul>
  <li>should each byte array be converted in a physical temp file, or can they be added to the ZIP in memory ?</li>
  <li>if yes, I know I'll have to handle the possible equality of names (they can have the same name in different records in the database, but not inside the same file system nor ZIP): are there any other possible problems that come to mind (assuming the file system always has enough physical space) ?</li>
  <li>since I can't rely on having enough RAM to perform the whole operation in memory, I guess the ZIP should be created and fed to the file system before being sent to the user; is there any way to do it differently (eg with <em>websocket</em>), like asking the user where to save the file, and then starting a constant flow of data from the server to client (<em>Sci-Fi</em> I guess) ?</li>
  <li>any other related known problems or best practices that cross your mind would be greatly appreciated.</li>
  </ul>