Single-file ZIP
Single-file ZIP is a ZIP Archive sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
single-file.zipArchive
複数ファイルを格納するアーカイブ形式。DOCX/XLSX/APK/JAR/EPUBなど多くの形式のコンテナでもあります。
50 4B 03 04 PK..50 4B 05 06 PK..50 4B 07 08 PK..SIGNATURE = bytes.fromhex("504b0304")
OFFSET = 0
def is_zip(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATUREconst SIGNATURE = [0x50, 0x4b, 0x03, 0x04];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isZip(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}package fileid
import "bytes"
var iszipSignature = []byte{0x50, 0x4b, 0x03, 0x04}
const iszipOffset = 0
func IsZip(b []byte) bool {
end := iszipOffset + len(iszipSignature)
if len(b) < end {
return false
}
return bytes.Equal(b[iszipOffset:end], iszipSignature)
}const SIGNATURE: &[u8] = &[0x50, 0x4b, 0x03, 0x04];
const OFFSET: usize = 0;
fn is_zip(bytes: &[u8]) -> bool {
bytes.get(OFFSET..OFFSET + SIGNATURE.len()) == Some(SIGNATURE)
}<?php
$signature = "\x50\x4b\x03\x04";
$offset = 0;
function is_zip(string $bytes): bool {
global $signature, $offset;
return substr($bytes, $offset, strlen($signature)) === $signature;
}ZIP Archive は圧縮、展開、バックアップ、添付、複数ファイルの検査に使われます。展開前にパス・ファイル数・圧縮後/展開後サイズを検証してください。
アーカイブには zip-slip パス、過剰な展開、隠しファイル、二重拡張子が含まれることがあります。展開パスを正規化し、ファイル数とサイズの上限を設けてください。
11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。
Single-file ZIP is a ZIP Archive sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
single-file.zipEmpty ZIP is a ZIP Archive sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
empty.zipTwo File ZIP is a ZIP Archive sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
two-files.zipBlue Sky ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
01-blue-sky.zip406899035ac2a5ebd7641aaf09b0026caf34ae6414f224801a2df79888baab21Flower Garden ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
02-flower-garden.zip9ff8454befd465893ed4f21427fb53aff3b830d7501e125445d32b27e6d71477Navy Blue Sky ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
03-navy-blue-sky.zip821a889e4ca078ef99efa381eaf06128e7859bf439ee3eb53f099eea43af5b13Nature of the Sky ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
04-nature-sky.zip4b7eef406dfa9120a46e419abf15f8d5fdd4b59f82e41548e895b3859d1c81eeSky Landscape ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
05-sky-landscape.zip1efa3a18f71d6235167237cdc8611dbacd9812b6aac86d5fdac2e87843a0a96fStarry Sky ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
06-starry-sky.zip9dea35b1174a734275f911257297b00a3f7269459b6f99becfc061f3e4cfeed1Blue Night Sky ZIP is a ZIP Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
07-blue-night-sky.zipae59106122a39caf2142ab9cb6947522d55b5afeba9d8d89fa63d5801fcb752bNASA Blue Marble ZIP is a ZIP Archive sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.
nasa-blue-marble-2012-east.zip527dd0ee5ce84bfea705fa242f5a9bd38c951d91f9c2c37f79ab8766612530dbZIP Archive ファイルはバイトシグネチャ 50 4B 03 04 ("PK..") または 50 4B 05 06 ("PK..") または 50 4B 07 08 ("PK..") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。
ZIP Archive のMIMEタイプは application/zip です。
ZIP Archive ファイルは .zip 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。