filesig
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Nodejs File Signature Validator

small library to validate Files by reading each magic number from a file

filesig Node CI

Requirements

  • Node version 12.x or higher

Install

$ npm install filesig

Usage

Simple

const filesig = require('filesig');
const fs = require('fs');

fs.readFile('/home/john/document.pdf', (err, data) => {
    if (err) {
        console.log(err);
    } else {
        console.log(filesig.isPdf(data));
    }
});

One of

const filesig = require('filesig');
const fs = require('fs');

fs.readFile('/home/john/Capture.PNG', (err, data) => {
    if (err) {
        console.log(err);
    } else {
        let valid = filesig.oneOf(data, filesig.is3gp, filesig.isJpeg, filesig.isPng);
        console.log(valid);
    }
});

Package Sidebar

Install

npm i filesig

Weekly Downloads

22

Version

1.0.4

License

MIT

Unpacked Size

37.2 kB

Total Files

36

Last publish

Collaborators

  • wuriyanto