Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Archive::Zip can only create zip-files in-memory, right?

by pmqs (Friar)
on Jul 26, 2014 at 16:19 UTC ( [id://1095166]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^3: Archive::Zip can only create zip-files in-memory, right?
by isync (Hermit) on Jul 27, 2014 at 14:25 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1095166]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-18 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found