wire / wire-format / zip-local-header
Each file in a ZIP archive begins with a 30-byte (minimum) local file header: signature 0x04034B50, version needed, flags, compression method, modtime, CRC-32, compressed/uncompressed sizes, filename length, extra field length, then the filename and extra field, then the (possibly compressed) file data.
aka: ZIP local file header
spec: PKWARE APPNOTE.TXT (ZIP format)
Each file in a ZIP archive begins with a 30-byte (minimum) local file header: signature 0x04034B50, version needed, flags, compression method, modtime, CRC-32, compressed/uncompressed sizes, filename length, extra field length, then the filename and extra field, then the (possibly compressed) file data.
| field | size | meaning |
|---|---|---|
| Signature | 4 bytes | 0x04034B50 ('PK\x03\x04'). |
| Version needed | 2 bytes | Minimum PKZIP version to extract (e.g. 20 = 2.0, 45 = 4.5 with ZIP64). |
| General purpose bit flag | 2 bytes | Bit 0 = encrypted, bit 3 = data descriptor follows, bit 11 = UTF-8 filename, ... . |
| Compression method | 2 bytes | 0 = stored, 8 = DEFLATE, 12 = BZIP2, 14 = LZMA, 98 = PPMd. |
| Last mod time | 2 bytes | MS-DOS time (5/6/5 bits for hour/min/sec*2). |
| Last mod date | 2 bytes | MS-DOS date (7/4/5 bits for year-1980/month/day). |
| CRC-32 | 4 bytes | CRC-32 of uncompressed data (0 if data descriptor used). |
| Compressed size | 4 bytes | Size of compressed data (0 if data descriptor used). |
| Uncompressed size | 4 bytes | Size of uncompressed data (0 if data descriptor used). |
| Filename length | 2 bytes | Length of the filename that follows. |
| Extra field length | 2 bytes | Length of the extra field that follows. |
| Filename | variable | The file's path/name (UTF-8 if flag bit 11 set). |
| Extra field | variable | Tagged extra data blocks (ZIP64, Unix uid/gid, NTFS timestamps, ...). |
example:
50 4b 03 04 14 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 1c 00 68 65 6c 6c 6f 2e 74 78 74
Local header for 'hello.txt', stored (method 0), empty extra
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/zip-local-header
or /wire-format/zip-local-header.json