in reply to Archive::Zip can only create zip-files in-memory, right? SOLVED

I thought a quick post on PM would bring clarity from someone who knows for sure in a short thread. (Saving me time of digging through the module's source.)
Now, with a number of nebulous answers, I begin to think, this is becoming more of a PM Medidation...

From what I've read since the original post, Archive::Zip can only build zips in-memory. *wrong*, read on (it's actually quite smart)
IO::Compress::Zip as an alternative has finer grained IO control, but offers less control over zip member (re-)naming.
  • Comment on Re: Archive::Zip can only create zip-files in-memory, right?

Replies are listed 'Best First'.
Re^2: Archive::Zip can only create zip-files in-memory, right?
by pmqs (Friar) on Jul 26, 2014 at 16:19 UTC

    Archive::Zip will "remember" all the actions you request done for the zip file, then do all of them in sequence when you do

    $zip->writeToFileNamed('someZip.zip')

    So if you are creating a zip based on real files from the filesystem, the contents of those files are not stored in memory. It just remembers the names of the files in memory.

    When you do make the writeToFileNamed call it reads the input files and writes the compressed data directly to the output filehandle for the zip file.

    Regarding Archive::Zip::SimpleZip - it does write to the zip file as soon as possible.

    One thing to be aware of though - the zip container format that gets used by 99% of all zip archives out in the wild needs to be written to a seekable filehandle when you are using Archive::Zip::SimpleZip. STDOUT is not seekable.

    Luckily, the Zip container spec does support a proper streaming format that can be used when writing to STDOUT. The issue then is to ensure that the client supports that type of Zip container. Most do these days.

    If you use Archive::Zip::SimpleZip with STDOUT, it will automatically create a streamed zip container. Whether that is acceptable depends on your clients.

    If you think there is an issue with member naming in Archive::Zip::SimpleZip I'd like to hear what is missing.

      Exhaustive answer. Thanks! +1
      And reveals that I haven't dug around in Archive::Zip's source enough...

      (Nothing's missing in SimpleZip, as it adds the sugar needed to add a member under a different name - what I think, from reading the POD, is not possible with IO::Compress::Zip alone.)
      Case closed.