STREAMZIP(1)

๐Ÿ’– STREAMZIP(1) ๐Ÿ’–

Okay bestie, welcome to STREAMZIP(1) from the Perl Programmers Reference Guide โ€” itโ€™s giving โ€œpipe your data in, get a zip out, no temp files, no drama.โ€ ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

streamzip โ€” create a zip file from stdin

โœจ SYNOPSIS โœจ

producer | streamzip [opts] | consumer
producer | streamzip [opts] -zipfile=output.zip

๐Ÿ’– DESCRIPTION ๐Ÿ’–

Okay so the whole gig: streamzip reads data from stdin, compresses it into a zip container, and by default writes a streamed zip file to stdout. No temporary files are created. Periodt. ๐Ÿ’…

The zip container written to stdout is, by necessity, written in streaming format. Most programs that read Zip files can cope with a streamed zip file, but if interoperability is important, and your workflow allows you to write the zip file directly to disk, you can create a non-streamed zip file using the zipfile option. โœจ

๐ŸŽ€ OPTIONS ๐ŸŽ€

Full menu, bestie โ€” every flag stays exactly as written. No skips, no merges, no invented options. ๐Ÿซถ

  • -zip64 โ€” Create a Zip64-compliant zip container. Use this option if the input is greater than 4Gig. Default is disabled.
  • -zipfile=F โ€” Write zip container to the filename F. Use the Stream option to force the creation of a streamed zip file.
  • -member-name=M โ€” This option is used to name the file in the zip container. Default is -.
  • -stream โ€” Ignored when writing to stdout. If the zipfile option is specified, including this option will trigger the creation of a streamed zip file. Default: Always enabled when writing to stdout, otherwise disabled.
  • -method=M โ€” Compress using method M. Valid method names are:
    • store โ€” Store without compression
    • deflate โ€” Use Deflate compression [Default]
    • bzip2 โ€” Use Bzip2 compression
    • lzma โ€” Use LZMA compression
    • xz โ€” Use xz compression
    • zstd โ€” Use Zstandard compression

Note that Lzma compress needs IO::Compress::Lzma to be installed.

Note that Zstd compress needs IO::Compress::Zstd to be installed.

Default is deflate.

  • -0, -1, -2, -3, -4, -5, -6, -7, -8, -9 โ€” Sets the compression level for deflate. Ignored for all other compression methods. -0 means no compression and -9 for maximum compression. Default is 6.
  • -version โ€” Display version number.
  • -help โ€” Display help.

๐ŸŒˆ Examples ๐ŸŒˆ

First up, the page says: Create a zip file bt reading daa from stdin โ€” yes, thatโ€™s the exact wording, and we respect the lore. ๐Ÿ˜Œ

$ echo Lorem ipsum dolor sit | perl ./bin/streamzip >abcd.zip

Check the contents of abcd,zip with the standard unzip utility:

Archive:  abcd.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       22  2021-01-08 19:45   -
---------                     -------
       22                     1 file

Notice how the Name is set to - โ€” thatโ€™s the default for a few zip utilities when the member name isnโ€™t given. ๐ŸŽ€

If you want to explicitly name the file, use the -member-name option as follows:

$ echo Lorem ipsum dolor sit | perl ./bin/streamzip -member-name latin >abcd.zip

$ unzip -l abcd.zip
Archive:  abcd.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       22  2021-01-08 19:47   latin
---------                     -------
       22                     1 file

๐Ÿฆ‹ When to write a Streamed Zip File ๐Ÿฆ‹

A Streamed Zip File is useful in situations where you cannot seek backwards/forwards in the file. ๐Ÿ”ฅ

A good example is when youโ€™re serving dynamic content from a Web Server straight into a socket without needing to create a temporary zip file in the filesystem. Literally iconic for pipelines. ๐ŸŒˆ

Similarly if your workflow uses a Linux pipelined commands. ๐Ÿงโœจ

๐Ÿซถ SUPPORT ๐Ÿซถ

General feedback/questions/bug reports should be sent to https://github.com/pmqs/IO-Compress/issues (preferred) or https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress.

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Paul Marquess pmqs@cpan.org. Main character energy, no cap. ๐Ÿ’œ

Copyright (c) 2019-2026 Paul Marquess. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Source/version check, bestie: perl v5.42.3, dated 2026-11-03 โ€” thatโ€™s the whole page, now go make some zip files and slay ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from