file in abyss
フォーマット一覧へ戻る

Archive

GZ GZIP Compressed Data

単一ストリームを圧縮する形式。先頭の1F 8Bに続き、圧縮方式として通常08が入ります。

Extensions .gz, .gzip
MIME application/gzip

マジックナンバー

ファイルを解析
オフセット 0 GZIP magic and deflate compression method
1F 8B 08
...

構造

  1. Header
  2. Optional metadata fields
  3. Compressed deflate blocks
  4. CRC32
  5. Input size

注意点

  • TAR.GZはGZIPで圧縮されたTARであり、先頭だけでは中身のTAR構造までは判定できません。

判定コード例

SIGNATURE = bytes.fromhex("1f8b08")
OFFSET = 0

def is_gz(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

GZIP Compressed Data は圧縮、展開、バックアップ、添付、複数ファイルの検査に使われます。展開前にパス・ファイル数・圧縮後/展開後サイズを検証してください。

よくある判定ミス

  • .gz / .gzip という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • GZIP Compressed Data は 1F 8B 08 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

アーカイブには zip-slip パス、過剰な展開、隠しファイル、二重拡張子が含まれることがあります。展開パスを正規化し、ファイル数とサイズの上限を設けてください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Arc

Small GZIP

Small GZIP is a GZIP Compressed Data sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

small.txt.gz
Type Sample
Small file
34 B
Generated CC0 1.0
SHA-256 caae4369709742dd5d2661229815ec5e9c7876593ab930fe2362e10d3398cf3a
Download
Arc

Empty GZIP

Empty GZIP is a GZIP Compressed Data sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

empty.gz
Type Sample
Small file
20 B
Generated CC0 1.0
SHA-256 abfbb86f9f5ddfbd9fc1a72c43ab384702ce8bae86b60f3324748485e235e61e
Download
Arc

Blue Sky TXT.GZ

Blue Sky TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.txt.gz
Type Sample
Small file
158 B
SHA-256 bd339e2f6ecde312ad681f2dbadacb5fa40f1272a989a46e48b6ae5412d3a86b
Download
Arc

Flower Garden TXT.GZ

Flower Garden TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.txt.gz
Type Sample
Small file
192 B
SHA-256 e347f058c65e3a70b8ebd7eec0df68eb345f88f13d96ff61c5ad4a6a0d3e3c14
Download
Arc

Navy Blue Sky TXT.GZ

Navy Blue Sky TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.txt.gz
Type Sample
Small file
184 B
SHA-256 f0ffbb194ac00c32c155e2ae64f5b11125fd4ade8bf8405f9cc2df876936eb66
Download
Arc

Nature of the Sky TXT.GZ

Nature of the Sky TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.txt.gz
Type Sample
Small file
178 B
SHA-256 26c4f012b0eb40487581dbbf95c2c6629a32b6a21aa83d47f2124794a548beb2
Download
Arc

Sky Landscape TXT.GZ

Sky Landscape TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.txt.gz
Type Sample
Small file
197 B
SHA-256 6e7bb216870b8130a07481215de2dc4f3e442b2a1bc94254e3acfbbf86fef4ba
Download
Arc

Starry Sky TXT.GZ

Starry Sky TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.txt.gz
Type Sample
Small file
179 B
SHA-256 5def2c45c82871e416c64efa4e58e1367bb3b22fac3f882b0cad04eb5c83fce6
Download
Arc

Blue Night Sky TXT.GZ

Blue Night Sky TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.txt.gz
Type Sample
Small file
181 B
SHA-256 e944abd9432452504192795441c70d4d411d2fb2d157704957a6e435e9f4d6d0
Download
Arc

Hibiscus Flower TXT.GZ

Hibiscus Flower TXT.GZ is a GZIP Compressed Data sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.txt.gz
Type Sample
Small file
204 B
SHA-256 e8d823308dd8f6c889030ff57aa5990f981864988e88b76436b08dc084bec84d
Download
Arc

NASA Blue Marble TXT.GZ

NASA Blue Marble TXT.GZ is a GZIP Compressed Data 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.txt.gz
Type Sample
Small file
235 B
SHA-256 4a3d9989895a7d7cfb77d26c5369c6d539ad763fa942f4f3c16ee79910dfe7d1
Download

よくある質問

GZIP Compressed Data のマジックナンバー(ファイルシグネチャ)は?

GZIP Compressed Data ファイルはバイトシグネチャ 1F 8B 08 ("...") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

GZIP Compressed Data のMIMEタイプは?

GZIP Compressed Data のMIMEタイプは application/gzip です。

GZIP Compressed Data の拡張子は?

GZIP Compressed Data ファイルは .gz, .gzip 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット