Gathering detailed insights and metrics for file-type-checker
Gathering detailed insights and metrics for file-type-checker
Gathering detailed insights and metrics for file-type-checker
Gathering detailed insights and metrics for file-type-checker
is-checker
Simple and light-weight JavaScript type checker that brings convenience!
simple-file-type-checker
Um utilitário simples para verificar se um tipo de arquivo é permitido com base em uma lista de tipos permitidos.
ts-dynamic-type-checker
TypeScript library that permorms dynamic type checking. It's useful for cases where you can't use TypeScript's static type checking (like reading a JSON object from a file).
vue-type-audit
A TypeScript error checker that supports Vue SFC(Single File Component). The world's only tool that runs type checking for both child components' prop types and event handler types on Vue template.
Detect and validate file types by their signatures (✨magic numbers✨)
npm install file-type-checker
Typescript
Module System
Node Version
NPM Version
97.2
Supply Chain
100
Quality
79.1
Maintenance
100
Vulnerability
100
License
TypeScript (99.42%)
JavaScript (0.58%)
Total Downloads
815,536
Last Day
685
Last Week
16,159
Last Month
74,905
Last Year
736,928
MIT License
24 Stars
33 Commits
6 Forks
3 Watchers
7 Branches
4 Contributors
Updated on Apr 01, 2025
Minified
Minified + Gzipped
Latest Version
1.1.4
Package Id
file-type-checker@1.1.4
Unpacked Size
153.40 kB
Size
23.95 kB
File Count
57
NPM Version
9.6.4
Node Version
20.0.0
Published on
Feb 08, 2025
Cumulative downloads
Total Downloads
Last Day
-7.9%
685
Compared to previous day
Last Week
-17.7%
16,159
Compared to previous week
Last Month
-13.2%
74,905
Compared to previous month
Last Year
840.6%
736,928
Compared to previous year
Detect and validate file types by their signatures (✨magic numbers✨)
Array<number>
, ArrayBuffer
, or Uint8Array
.1import fileTypeChecker from "file-type-checker";
2
3// ... Read file as `Array<number>`, `ArrayBuffer`, or `Uint8Array`.
4
5fileTypeChecker.detectFile(file); // Returns the detected file info
6fileTypeChecker.validateFileType(file, ["png", "gif", "jpeg"]); // Returns true if the file includes an image signature from the accepted list
7fileTypeChecker.isPNG(file); // Returns true if the file includes a valid PNG image signature
8
9// ... And many more validator functions for each supported type.
Using npm:
npm i file-type-checker
Type |
---|
7z |
aac |
amr |
avi |
bmp |
bpg |
blend |
cr2 |
doc |
elf |
exe |
exr |
flac |
flv |
gif |
heic |
ico |
indd |
jpeg |
lzh |
m4a |
m4v |
mach-o |
mkv |
mov |
mp3 |
mp4 |
ogg |
pcap |
pbm |
pgm |
png |
ppm |
psd |
ps |
rar |
rtf |
sqlite |
stl |
swf |
ttf |
wav |
webm |
webp |
zip |
⚠️ Note: These examples demonstrate reading the entire file, which may be slow for large files. For optimized handling of large files, refer to the Optimization section.
React
, Angular
, Vanilla JS
, etc.):Validate file signature against a list if file types (React app example):
1import fileTypeChecker from "file-type-checker"; 2 3// Function to handle file input change 4const handleFileInputChange = (event) => { 5 try { 6 const file = event.target.files[0]; 7 const reader = new FileReader(); 8 const types = ["jpeg", "png", "gif"]; 9 10 // When the file is loaded, validate its type 11 reader.onload = () => { 12 const isImage = fileTypeChecker.validateFileType(reader.result, types); 13 console.log(isImage); // Returns true if the file includes an image signature from the accepted list 14 }; 15 16 // Use the FileReader API to read the file as an ArrayBuffer 17 reader.readAsArrayBuffer(file); 18 } catch (err) { 19 console.error("Error: ", err.message); 20 } 21}; 22 23return ( 24 <div> 25 <input type="file" onChange={handleFileInputChange} /> 26 </div> 27);
1import fileTypeChecker from "file-type-checker"; 2 3// Function to handle file input change 4const handleFileInputChange = (event) => { 5 try { 6 const file = event.target.files[0]; 7 const reader = new FileReader(); 8 const types = ["mp4", "avi", "mov"]; 9 10 // When the file is loaded, validate its type 11 reader.onload = () => { 12 const isVideo = fileTypeChecker.validateFileType( 13 reader.result, 14 types, 15 { excludeSimilarTypes: true } // (optional parameter) if we don't want to validate 'm4a' signature as 'mp4' type 16 ); 17 console.log(isVideo); // Returns true if the file includes a video signature from the accepted list 18 }; 19 20 // Use the FileReader API to read the file as an ArrayBuffer 21 reader.readAsArrayBuffer(file); 22 } catch (err) { 23 console.error("Error: ", err.message); 24 } 25}; 26 27return ( 28 <div> 29 <input type="file" onChange={handleFileInputChange} /> 30 </div> 31);
Validate file signature against a single file type (React app example):
1import fileTypeChecker from "file-type-checker"; 2 3// Function to handle file input change 4const handleFileInputChange = (event) => { 5 try { 6 const file = event.target.files[0]; 7 const reader = new FileReader(); 8 9 // When the file is loaded, check if its type is PNG 10 reader.onload = () => { 11 const isPNG = fileTypeChecker.isPNG(reader.result); 12 console.log(isPNG); // Returns true if the file includes a vali PNG image signature 13 }; 14 15 // Use the FileReader API to read the file as an ArrayBuffer 16 reader.readAsArrayBuffer(file); 17 } catch (err) { 18 console.error("Error validating file type: ", err.message); 19 } 20}; 21 22return ( 23 <div> 24 <input type="file" onChange={handleFileInputChange} /> 25 </div> 26);
Detect file by its signature (React app example):
1import fileTypeChecker from "file-type-checker"; 2 3// Function to handle file input change 4const handleFileInputChange = (event) => { 5 try { 6 const file = event.target.files[0]; 7 const reader = new FileReader(); 8 9 // When the file is loaded, detect its type 10 reader.onload = () => { 11 const detectedFile = fileTypeChecker.detectFile(reader.result); 12 console.log(detectedFile) > 13 { 14 extension: "png", 15 mimeType: "image/png", 16 description: 17 "PNG (Portable Network Graphics) is a lossless image compression format that supports a wide range of color depths and transparency and is widely used for high-quality graphics.", 18 signature: { 19 sequence: ["89", "50", "4e", "47", "d", "a", "1a", "a"], 20 }, 21 }; 22 }; 23 24 // Use the FileReader API to read the file as an ArrayBuffer 25 reader.readAsArrayBuffer(file); 26 } catch (err) { 27 console.error("Error: ", err.message); 28 } 29}; 30 31return ( 32 <div> 33 <input type="file" onChange={handleFileInputChange} /> 34 </div> 35);
Detect file by its signature (synchronously, will be slow with large files):
1import fileTypeChecker from "file-type-checker"; 2import fs from "fs"; 3 4// Read a file as an ArrayBuffer 5const file = fs.readFileSync("/path/to/my/file.mp4").buffer; 6 7const detectedFile = fileTypeChecker.detectFile(file); 8 9console.log(detectedFile) 10> { 11 "extension": "mp4", 12 "mimeType": "video/mp4", 13 "description": "A multimedia container format widely used for storing audio, video, and other data, and is known for its high compression efficiency and compatibility with many devices", 14 "signature": { 15 "sequence": ["66","74","79","70","69","73","6f","6d"], 16 "description" (optional): "ISO Base Media file (MPEG-4) v1", 17 "offset" (optional): 4 18 } 19 }
Validate file signature against a list of file types:
1import fileTypeChecker from "file-type-checker"; 2import fs from "fs"; 3//const fileTypeChecker = require("file-type-checker"); // legacy way 4//const fs = require("fs"); // legacy way 5 6// Read a file as an ArrayBuffer 7const file = fs.readFileSync("/path/to/my/file.png").buffer; 8 9// A list of accepted image file types 10const types = ["jpeg", "png", "gif"]; 11 12const isImage = fileTypeChecker.validateFileType( 13 file, 14 types, 15 { chunkSize: 32 } // (optional parameter) all images signatures exists in the first 32 bytes 16); 17 18console.log(isImage); // Returns true the file includes an image signature from the accepted list
Validate file signature against a single file type:
1import fileTypeChecker from "file-type-checker"; 2import fs from "fs"; 3//const fileTypeChecker = require("file-type-checker"); // legacy way 4//const fs = require("fs"); // legacy way 5 6// Read a file as an ArrayBuffer 7const file = fs.readFileSync("/path/to/my/file.png").buffer; 8 9const isPNG = fileTypeChecker.isPNG(file); 10 11console.log(isPNG); // Returns true if the file includes a valid PNG image signature
file-type-checker
efficientlyTo ensure the best performance and avoid excessive memory usage, follow these best practices:
Read only the first X bytes when detecting file type.
Most file signatures exist in the first 64 bytes, except ZIP files that require 32,000 bytes.
Before calling detectFile
, validateFile
or any other validation function, make sure you only pass a chunk from the beginning of the file content.
This reduces unnecessary file I/O and memory consumption.
✅ Node.js example (read first 64 bytes for detection)
import fileTypeChecker from "file-type-checker";
import fs from "fs";
import path from "path";
const file = path.resolve("/path/to/my/large/file.mp4");
const CHUNK_SIZE = 64; // All file signatures except ZIP exist in the first 64 bytes
const fileHandle = await fs.promises.open(file, "r");
const buffer = Buffer.alloc(CHUNK_SIZE);
await fileHandle.read(buffer, 0, CHUNK_SIZE, 0); // Read only the first 64 bytes
// Detect file type using the first chunk
const detectedFileInfo = fileTypeChecker.detectFile(buffer, {
chunkSize: 64,
});
✅ Browser example (read first 64 bytes using file.slice() ):
import fileTypeChecker from "file-type-checker";
const handleFileInputChange = async (event) => {
try {
const file = event.target.files[0];
// Read only the first 64 bytes for file type detection (optimization)
const buffer = await file.slice(0, 64).arrayBuffer();
const detectedFile = fileTypeChecker.detectFile(buffer);
console.log("Detected File Type:", detectedFile);
} catch (err) {
console.error("Error: ", err.message);
}
};
return <input type="file" onChange={handleFileInputChange} />;
Process large files in chunks.
Avoid loading the entire file into memory at once.
Most file signatures exist in the first 64 bytes, except ZIP files that require 32,000 bytes.
Process files in small chunks instead of reading everything at once.
✅ Node.js example (read large files in chunks)
import fileTypeChecker from "file-type-checker";
import fs from "fs";
const readFileInChunks = (filePath, chunkSize = 64 * 1024) => {
const stream = fs.createReadStream(filePath, { highWaterMark: chunkSize });
let isFirstChunk = true; // Flag to track the first chunk
stream.on("data", (chunk) => {
console.log("Chunk read:", chunk);
if (isFirstChunk) {
const detectedFile = fileTypeChecker.detectFile(chunk);
console.log("Detected File Type:", detectedFile);
isFirstChunk = false; // Prevent further calls to detectFile
}
});
stream.on("end", () => console.log("Finished reading file."));
};
readFileInChunks("/path/to/my/large/file.mp4");
✅ Browser example (read large files using streams)
import fileTypeChecker from "file-type-checker";
const readFileInChunks = async (file, chunkSize = 64 * 1024) => {
console.log(`Reading file in chunks of ${chunkSize} bytes`);
const stream = file.stream();
const reader = stream.getReader();
let isFirstChunk = true;
let done = false;
while (!done) {
const { value, done: isDone } = await reader.read();
done = isDone; // Update loop condition
if (value) {
console.log("Chunk read:", value);
if (isFirstChunk) {
const detectedFile = fileTypeChecker.detectFile(value);
console.log("Detected File Type:", detectedFile);
isFirstChunk = false; // Prevent further calls to detectFile
}
}
}
console.log("Finished reading file.");
};
const handleFileInputChange = (event) => {
if (!event.target.files.length) return;
readFileInChunks(event.target.files[0]);
};
return <input type="file" onChange={handleFileInputChange} />;
Detect the file type of a given file.
1import fileTypeChecker from "file-type-checker"; 2 3// ... 4 5const detectedFile = fileTypeChecker.detectFile(file); 6> { 7 "extension": "png", 8 "mimeType": "image/png", 9 "description": "PNG (Portable Network Graphics) is a lossless image compression format that supports a wide range of color depths and transparency and is widely used for high-quality graphics.", 10 "signature": { 11 "sequence": ["89","50","4e","47","d","a","1a","a"] 12 } 13 }
Parameters:
file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
options
(optional) : object
- An object that contains additional actions to perfoem on the file:
chunkSize
(optional) : number
- Specifies the size of the file chunk to analyze, starting from the beginning of the file. For ZIP files, it is recommended to set this to 30,000 bytes for accurate detection. The default value is 64. The default value is 64.
⚠️ Note: For optimized handling of large files, refer to the Optimization section.
Returns:
object
- An object with information about a file, including its file extension, MIME type, and file signature. The returned object has the following properties:
extension
- A string that represents file extension (e.g., "png").mimeType
- A string that represents the MIME type of the file (e.g., "image/png").description
- A string that provides a short description of the file.signature
- An object that contains information about the file signature, with the following properties:
sequence
- An array of hexadecimal strings that represents the bytes in the file signature.description
(optional) - A string that provides a short description of the file signature.offset
(optional) - A number that indicates the offset of the file signature.skippedBytes
(optional) - An array of numbers that indicates the number of bytes that were skipped.compatibleExtensions
(optional): An array of strings that indicates file compatible extensions.undefined
- If no file has found.Validates the requested file signature against a list of accepted file types.
1import fileTypeChecker from "file-type-checker"; 2 3// ... 4 5const isImage = fileTypeChecker.validateFileType(file, ["jpeg", "png", "gif"]); 6console.log(isImage); // Returns true the file includes an image signature from the accepted list
Parameters:
file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
types
: Array<string>
- A list of accepted file types (from our supported files).
options
(optional) : object
- An object that contains additional actions to perfoem on the file:
chunkSize
(optional) : number
- Specifies the size of the file chunk to analyze, starting from the beginning of the file. For compressed files, it is recommended to set this to 30,000 bytes when validating ZIP files. The default value is 64.
⚠️ Note: For optimized handling of large files, refer to the Optimization section.
excludeSimilarTypes
(optional) : boolean
- Specifies whether to ignore signatures of similar file types during validation. When validating a mp4
file, the m4v
signature will be ignored. When validating a m4a
file, the aac
signature will be ignored. The default value is false.
Returns a boolean
indicating whether the file is valid.
All supported files have validator functions that determine if a given file matched the requested type signature.
1import fileTypeChecker from "file-type-checker"; 2 3// ... 4 5const is7z = fileTypeChecker.is7z(file); // Returns true if the file includes a valid 7z archive signature 6const isAAC = fileTypeChecker.isAAC(file); // Returns true if the file includes a valid AAC audio file signature 7const isAMR = fileTypeChecker.isAMR(file); // Returns true if the file includes a valid AMR audio file signature 8const isAVI = fileTypeChecker.isAVI(file); // Returns true if the file includes a valid AVI video file signature 9const isBMP = fileTypeChecker.isBMP(file); // Returns true if the file includes a valid BMP image signature 10const isBPG = fileTypeChecker.isBPG(file); // Returns true if the file includes a valid BPG image signature 11const isBLEND = fileTypeChecker.isBLEND(file); // Returns true if the file includes a valid Blender 3D file signature 12const isCR2 = fileTypeChecker.isCR2(file); // Returns true if the file includes a valid Canon CR2 raw image signature 13const isDOC = fileTypeChecker.isDOC(file); // Returns true if the file includes a valid DOC file signature 14const isELF = fileTypeChecker.isELF(file); // Returns true if the file includes a valid ELF executable file signature 15const isEXR = fileTypeChecker.isEXR(file); // Returns true if the file includes a valid EXR image signature 16const isEXE = fileTypeChecker.isEXE(file); // Returns true if the file includes a valid EXE image signature 17const isFLAC = fileTypeChecker.isFLAC(file); // Returns true if the file includes a valid FLAC audio file signature 18const isFLV = fileTypeChecker.isFLV(file); // Returns true if the file includes a valid FLV video file signature 19const isGIF = fileTypeChecker.isGIF(file); // Returns true if the file includes a valid GIF image signature 20const isHEIC = fileTypeChecker.isHEIC(file); // Returns true if the file includes a valid HEIC image signature 21const isICO = fileTypeChecker.isICO(file); // Returns true if the file includes a valid ICO image signature 22const isINDD = fileTypeChecker.isINDD(file); // Returns true if the file includes a valid Adobe InDesign document signature 23const isJPEG = fileTypeChecker.isJPEG(file); // Returns true if the file includes a valid JPEG image signature 24const isLZH = fileTypeChecker.isLZH(file); // Returns true if the file includes a valid LZH archive signature 25const isM4A = fileTypeChecker.isM4A(file); // Returns true if the file includes a valid M4A audio file signature 26const isM4V = fileTypeChecker.isM4V(file); // Returns true if the file includes a valid M4V video file signature 27const isMACHO = fileTypeChecker.isMACHO(file); // Returns true if the file includes a valid MACH-O video file 28const isMKV = fileTypeChecker.isMKV(file); // Returns true if the file includes a valid MKV video file signature 29const isMOV = fileTypeChecker.isMOV(file); // Returns true if the file includes a valid MOV video file signature 30const isMP3 = fileTypeChecker.isMP3(file); // Returns true if the file includes a valid MP3 audio file signature 31const isMP4 = fileTypeChecker.isMP4(file); // Returns true if the file includes a valid MP4 video file signature 32const isOGG = fileTypeChecker.isOGG(file); // Returns true if the file includes a valid OGG audio file signature 33const isORC = fileTypeChecker.isORC(file); // Returns true if the file includes a valid ORC file signature 34const isPARQUET = fileTypeChecker.isPARQUET(file); // Returns true if the file includes a valid Parquet file signature 35const isPBM = fileTypeChecker.isPBM(file); // Returns true if the file includes a valid PBM image signature 36const isPCAP = fileTypeChecker.isPCAP(file); // Returns true if the file includes a valid PCAP file signature 37const isPDF = fileTypeChecker.isPDF(file); // Returns true if the file includes a valid PDF document signature 38const isPGM = fileTypeChecker.isPGM(file); // Returns true if the file includes a valid PGM image signature 39const isPNG = fileTypeChecker.isPNG(file); // Returns true if the file includes a valid PNG image signature 40const isPPM = fileTypeChecker.isPPM(file); // Returns true if the file includes a valid PPM image 41const isPSD = fileTypeChecker.isPSD(file); // Returns true if the file includes a valid PSD image signature 42const isPS = fileTypeChecker.isPS(file); // Returns true if the file includes a valid PostScript file signature 43const isRAR = fileTypeChecker.isRAR(file); // Returns true if the file includes a valid RAR archive signature 44const isRTF = fileTypeChecker.isRTF(file); // Returns true if the file includes a valid RTF document signature 45const isSQLite = fileTypeChecker.isSQLite(file); // Returns true if the file includes a valid SQLite database file signature 46const isSTL = fileTypeChecker.isSTL(file); // Returns true if the file includes a valid STL 3D model file signature 47const isSWF = fileTypeChecker.isSWF(file); // Returns true if the file includes a valid SWF file signature 48const isTTF = fileTypeChecker.isTTF(file); // Returns true if the file includes a valid TrueType font file signature 49const isWAV = fileTypeChecker.isWAV(file); // Returns true if the file includes a valid WAV audio file signature 50const isWEBM = fileTypeChecker.isWEBM(file); // Returns true if the file includes a valid WebM video file signature 51const isWEBP = fileTypeChecker.isWEBP(file); // Returns true if the file includes a valid WebP image file signature 52const isZIP = fileTypeChecker.isZIP(file); // Returns true if the file includes a valid ZIP archive signature
Checks whether a file is a BMP image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid BMP image signature.
Checks whether a file is a BPG image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid BPG image signature.
Checks whether a file is a CR2 image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid CR2 image signature.
Checks whether a file is a EXR image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid EXR image signature.
Checks whether a file is a GIF image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid GIF image signature.
Checks whether a file is a HEIC image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid HEIC image signature.
Checks whether a file is an ICO image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid ICO image signature.
Checks whether a file is a JPEG image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid JPEG image signature.
Checks whether a file is a PBM image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PBM image signature.
Checks whether a file is a PGM image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PGM image signature.
Checks whether a file is a PNG image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PNG image signature.
Checks whether a file is a PPM image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PPM image signature.
Checks whether a file is a PSD image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PSD image signature.
Checks whether a file is a TTF image by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid TTF image signature.
Checks whether a file is an AVI video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid AVI video signature.
Checks whether a file is a FLV video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid FLV video signature.
Checks whether a file is a M4v video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid M4v video signature.
Checks whether a file is a MKV video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid MKV video signature.
Checks whether a file is a MOV video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid MOV video signature.
Checks whether a file is a MP4 video by inspecting its file signature.
Parameters:
file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
options
(optional) : object
- An object that contains additional actions to perfoem on the file:
excludeSimilarTypes
(optional) : boolean
- Specifies whether to ignore signatures of similar file types during validation. When validating a mp4
file, the m4v
signature will be ignored. The default value is false.Returns a boolean
indicating whether the file includes a valid MP4 video signature.
Checks whether a file is an OGG video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid OGG video signature.
Checks whether a file is a SWF video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid SWF video signature.
Checks whether a file is a WEBM video by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid WEBM video signature.
Checks whether a file is an AAC audio by inspecting its file signature.
Parameters:
file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
options
(optional) : object
- An object that contains additional actions to perfoem on the file:
excludeSimilarTypes
(optional) : boolean
- Specifies whether to ignore signatures of similar file types during validation. When validating a aac
file, the m4a
signature will be ignored. The default value is false.Returns a boolean
indicating whether the file includes a valid AAC audio signature.
Checks whether a file is an AMR audio by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid AMR audio signature.
Checks whether a file is a FLAC audio by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid FLAC audio signature.
Checks whether a file is a M4A audio by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid M4A audio signature.
Checks whether a file is a MP3 audio by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid MP3 audio signature.
Checks whether a file is a WAV audio by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid WAV audio signature.
Checks whether a file is a 7z compressed archive by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid 7z file signature.
Checks whether a file is a LZH compressed archive by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid LZH file signature.
Checks whether a file is a RAR compressed archive by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid RAR file signature.
Checks whether a file is a ZIP compressed archive by inspecting its file signature.
Parameters:
file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
options
(optional) : object
- An object that contains additional actions to perfoem on the file:
chunkSize
(optional) : number
- Specifies the size of the file chunk to analyze, starting from the beginning of the file. For ZIP files, it is recommended to set this to 30,000 bytes. The default value is 64.Returns a boolean
indicating whether the file includes a valid ZIP file signature.
Checks whether a file is a BLEND file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid BLEND file signature.
Checks whether a file is a DOC file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid DOC file signature.
Checks whether a file is an ELF file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid ELF file signature.
Checks whether a file is an EXE file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid EXE file signature.
Checks whether a file is an INDD file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file is an INDD file.
Checks whether a file is an MACH-O file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file is an MACH-O file.
Checks whether a file is a ORC file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid ORC file signature.
Checks whether a file is a PARQUET file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PARQUET file signature.
Checks whether a file is a PCAP file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PCAP file signature.
Checks whether a file is a PDF file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PDF file signature.
Checks whether a file is a PS file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid PS file signature.
Checks whether a file is a RTF file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid RTF file signature.
Checks whether a file is a SQLITE file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid SQLITE file signature.
Checks whether a file is a STL file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid STL file signature.
Checks whether a file is a TTF file by inspecting its file signature.
Parameters: - file
: Array<number>
, ArrayBuffer
, or Uint8Array
- Binary data represents the file content.
Returns a boolean
indicating whether the file includes a valid TTF file signature.
No vulnerabilities found.
No security vulnerabilities found.