title: Run out of memory writing files to zip with flysystem
body: <p>I'm programming a tool that gathers images uploaded by a user into a zip-archive. For this I came across ZipArchiveAdapter from Flysystem that seems to do a good job. </p>
  
  <p>I'm encountering an issue with the memory limit when the amount of files in the zip archive goes into the thousands. </p>
  
  <p>When the amount of images for a user starts to go beyond a 1000 it usually fails due to the available memory being exhausted. To get to the point where it seems to handle most users with less than 1000 images I've increased memory limit to 4GB, but increasing it beyond this is not really an option. </p>
  
  <p>Simplified code at this point: </p>
  
  <pre><code>&lt;?php
  use League\Flysystem\Filesystem;
  use League\Flysystem\ZipArchive\ZipArchiveAdapter;
  use League\Flysystem\Memory\MemoryAdapter;
  
  class User {
      // ... Other user code
  
      public function createZipFile()
      {
          $tmpFile = tempnam('/tmp', "zippedimages_");
          $download = new FileSystem(new ZipArchiveAdapter($tmpFile));
  
          if ($this-&gt;getImageCount()) {
              foreach ($this-&gt;getImages() as $image) {
                  $path_in_zip = "My Images/{$image-&gt;category-&gt;title}/{$image-&gt;id}_{$image-&gt;image-&gt;filename}";
                  $download-&gt;write($path_in_zip, $image-&gt;image-&gt;getData());
              }
          }
          $download-&gt;getAdapter()-&gt;getArchive()-&gt;close();
          return $tmpFile;
  
          // Upload zip to s3-storage
      }
  }
  </code></pre>
  
  <p>So my questions:
  a) Is there a way to have Flysystem write to the zip-file "on the go" to disk? Currently it stores the entire zip in memory before writing to disk when the object is destroyed. </p>
  
  <p>b) Should I utilize another library that would be better for this? </p>
  
  <p>c) Should I take another approach here? For example having the user download multiple smaller zips instead of one large zip. (Ideally I want them to download just one file regardless)</p>