Skip to content

Commit c4abedc

Browse files
kwkellyKeith Kelly
andauthored
feat: Add parquet file detection (#578)
Adds parquet file detection. See [docs](https://parquet.apache.org/docs/file-format/) for specification Co-authored-by: Keith Kelly <kkelly@morningconsult.com>
1 parent 4cc383c commit c4abedc

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

internal/magic/binary.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ var (
2121
SWF = prefix([]byte("CWS"), []byte("FWS"), []byte("ZWS"))
2222
// Torrent has bencoded text in the beginning.
2323
Torrent = prefix([]byte("d8:announce"))
24+
// PAR1 matches a parquet file.
25+
Par1 = prefix([]byte{0x50, 0x41, 0x52, 0x31})
2426
)
2527

2628
// Java bytecode and Mach-O binaries share the same magic number.

supported_mimes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 175 Supported MIME types
1+
## 176 Supported MIME types
22
This file is automatically generated when running tests. Do not edit manually.
33

44
Extension | MIME type | Aliases
@@ -143,6 +143,7 @@ Extension | MIME type | Aliases
143143
**.glb** | model/gltf-binary | -
144144
**.cab** | application/x-installshield | -
145145
**.jxr** | image/jxr | image/vnd.ms-photo
146+
**.parquet** | application/vnd.apache.parquet | application/x-parquet
146147
**.txt** | text/plain | -
147148
**.html** | text/html | -
148149
**.svg** | image/svg+xml | -

testdata/parquet.parquet

1.64 KB
Binary file not shown.

tree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var root = newMIME("application/octet-stream", "",
2323
avi, flv, mkv, asf, aac, voc, m3u, rmvb, gzip, class, swf, crx, ttf, woff,
2424
woff2, otf, ttc, eot, wasm, shx, dbf, dcm, rar, djvu, mobi, lit, bpg,
2525
sqlite3, dwg, nes, lnk, macho, qcp, icns, hdr, mrc, mdb, accdb, zstd, cab,
26-
rpm, xz, lzip, torrent, cpio, tzif, xcf, pat, gbr, glb, cabIS, jxr,
26+
rpm, xz, lzip, torrent, cpio, tzif, xcf, pat, gbr, glb, cabIS, jxr, parquet,
2727
// Keep text last because it is the slowest check.
2828
text,
2929
)
@@ -258,4 +258,6 @@ var (
258258
xfdf = newMIME("application/vnd.adobe.xfdf", ".xfdf", magic.Xfdf)
259259
glb = newMIME("model/gltf-binary", ".glb", magic.Glb)
260260
jxr = newMIME("image/jxr", ".jxr", magic.Jxr).alias("image/vnd.ms-photo")
261+
parquet = newMIME("application/vnd.apache.parquet", ".parquet", magic.Par1).
262+
alias("application/x-parquet")
261263
)

0 commit comments

Comments
 (0)