Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/telkomdev/node-filesig
validate Files by reading each magic number from a file for Nodejs
https://github.com/telkomdev/node-filesig
file-upload file-validation javascript nodejs
Last synced: about 5 hours ago
JSON representation
validate Files by reading each magic number from a file for Nodejs
- Host: GitHub
- URL: https://github.com/telkomdev/node-filesig
- Owner: telkomdev
- License: mit
- Created: 2022-07-14T12:57:57.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T05:03:29.000Z (7 months ago)
- Last Synced: 2024-11-08T21:46:32.613Z (8 days ago)
- Topics: file-upload, file-validation, javascript, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/filesig
- Size: 61.5 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Nodejs File Signature Validator
small library to validate Files by reading each magic number from a file
[![filesig Node CI](https://github.com/telkomdev/node-filesig/actions/workflows/ci.yml/badge.svg)](https://github.com/telkomdev/node-filesig/actions/workflows/ci.yml)
#### Requirements
- Node version 12.x or higher#### Install
```shell
$ npm install filesig
```#### Usage
Simple
```javascript
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
```javascript
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);
}
});
```