Am I overseeing something? I'd like to create (possibly) large zip-files in a web-app, and from my reading of
Archive::Zip, it has no means to write to a (temp) file on disk - right?
If so, any options besides
system("zip ...")?
Update:
My question might be misunderstood. I'm not asking about outputting to file, but about when the file is being assembled, when the zip grows, members being added, etc. - all that happens in memory, not on disk. So a, let's say, 150MB zip will take up 150MB RAM until it is written to disk, right?
(and let's put aside that this process may take some time and a web-app would block until the zip is done... - all that better be laid off into an async process...)
Update 2:
Archive::Zip::SimpleZip can do it.
It's a wrapper around IO::Compress::Zip and offers an interface similar to Archive::Zip, only it is able to "bind" it to a real/on-disk file on OO construction, and will then write added members to disk as they arrive.
That said/found, for my webapp scenario, it's probably less ideal to build a file to disk, having disk trashing in favour of a small memory footprint, and then
send_file that to the client. A better solution is probalby to use Archive::Zip::SimpleZip's ability to output a streamed zip to STDOUT, so the file is transmitted to the client while it grows, memory footprint is low, and disk IO is only read()s for adding members.
Update 3:
Archive::Zip and
Archive::Zip::SimpleZip are both able to build a zip file while keeping memory footprint low. (See pmqs's answer for the why and how)
There are small differences in behaviour though, for example A::Z::SimpleZip might be more appropriate when your zip member contents are not coming from file-system.