Skip to content

basalt / files/src / sniffContentType

Function: sniffContentType() ​

> sniffContentType(bytes): string | null

Defined in: files/src/sniff.ts:175

The built-in sniffer. Recognises PDF, PNG, JPEG, GIF, WebP, TIFF (both byte orders), ZIP and OOXML (docx/xlsx/pptx), HTML, SVG and XML text, and native executables (PE/MZ, ELF, Mach-O, #! scripts). Returns null for anything else — plain text, CSV, and formats it has no signature for.

Parameters ​

bytes ​

Uint8Array

Returns ​

string | null

Released under the MIT License.