1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "STREAMZIP 1"
.TH STREAMZIP 1 2023-12-15 "perl v5.38.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
streamzip \- create a zip file from stdin
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 2
\& producer | streamzip [opts] | consumer
\& producer | streamzip [opts] \-zipfile=output.zip
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
This program will read data from \f(CW\*(C`stdin\*(C'\fR, compress it into a zip container
and, by default, write a \fIstreamed\fR zip file to \f(CW\*(C`stdout\*(C'\fR. No temporary
files are created.
.PP
The zip container written to \f(CW\*(C`stdout\*(C'\fR 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 \f(CW\*(C`zipfile\*(C'\fR option.
.SS OPTIONS
.IX Subsection "OPTIONS"
.IP \-zip64 5
.IX Item "-zip64"
Create a Zip64\-compliant zip container. Use this option if the input is
greater than 4Gig.
.Sp
Default is disabled.
.IP \-zipfile=F 5
.IX Item "-zipfile=F"
Write zip container to the filename \f(CW\*(C`F\*(C'\fR.
.Sp
Use the \f(CW\*(C`Stream\*(C'\fR option to force the creation of a streamed zip file.
.IP \-member\-name=M 5
.IX Item "-member-name=M"
This option is used to name the "file" in the zip container.
.Sp
Default is '\-'.
.IP \-stream 5
.IX Item "-stream"
Ignored when writing to \f(CW\*(C`stdout\*(C'\fR.
.Sp
If the \f(CW\*(C`zipfile\*(C'\fR option is specified, including this option will trigger
the creation of a streamed zip file.
.Sp
Default: Always enabled when writing to \f(CW\*(C`stdout\*(C'\fR, otherwise disabled.
.IP \-method=M 5
.IX Item "-method=M"
Compress using method \f(CW\*(C`M\*(C'\fR.
.Sp
Valid method names are
.Sp
.Vb 6
\& * store Store without compression
\& * deflate Use Deflate compression [Deflault]
\& * bzip2 Use Bzip2 compression
\& * lzma Use LZMA compression
\& * xz Use xz compression
\& * zstd Use Zstandard compression
.Ve
.Sp
Note that Lzma compress needs \f(CW\*(C`IO::Compress::Lzma\*(C'\fR to be installed.
.Sp
Note that Zstd compress needs \f(CW\*(C`IO::Compress::Zstd\*(C'\fR to be installed.
.Sp
Default is \f(CW\*(C`deflate\*(C'\fR.
.IP "\-0, \-1, \-2, \-3, \-4, \-5, \-6, \-7, \-8, \-9" 5
.IX Item "-0, -1, -2, -3, -4, -5, -6, -7, -8, -9"
Sets the compression level for \f(CW\*(C`deflate\*(C'\fR. Ignored for all other compression methods.
.Sp
\&\f(CW\-0\fR means no compression and \f(CW\-9\fR for maximum compression.
.Sp
Default is 6
.IP \-version 5
.IX Item "-version"
Display version number
.IP \-help 5
.IX Item "-help"
Display help
.SS Examples
.IX Subsection "Examples"
Create a zip file bt reading daa from stdin
.PP
.Vb 1
\& $ echo Lorem ipsum dolor sit | perl ./bin/streamzip >abcd.zip
.Ve
.PP
Check the contents of \f(CW\*(C`abcd,zip\*(C'\fR with the standard \f(CW\*(C`unzip\*(C'\fR utility
.PP
.Vb 6
\& Archive: abcd.zip
\& Length Date Time Name
\& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\- \-\-\-\-\- \-\-\-\-
\& 22 2021\-01\-08 19:45 \-
\& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-
\& 22 1 file
.Ve
.PP
Notice how the \f(CW\*(C`Name\*(C'\fR is set to \f(CW\*(C`\-\*(C'\fR.
That is the default for a few zip utilities whwre the member name is not given.
.PP
If you want to explicitly name the file, use the \f(CW\*(C`\-member\-name\*(C'\fR option as follows
.PP
.Vb 1
\& $ 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
.Ve
.SS "When to write a Streamed Zip File"
.IX Subsection "When to write a Streamed Zip File"
A Streamed Zip File is useful in situations where you cannot seek
backwards/forwards in the file.
.PP
A good examples is when you are serving dynamic content from a Web Server
straight into a socket without needing to create a temporary zip file in
the filesystsm.
.PP
Similarly if your workfow uses a Linux pipelined commands.
.SH SUPPORT
.IX Header "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>.
.SH AUTHOR
.IX Header "AUTHOR"
Paul Marquess \fIpmqs@cpan.org\fR.
.SH COPYRIGHT
.IX Header "COPYRIGHT"
Copyright (c) 2019\-2022 Paul Marquess. All rights reserved.
.PP
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
|