archive-type

Detect the archive type of a Buffer/Uint8Array

archive-type

Detect the archive type of a Buffer/Uint8Array

See archive-type-cli for the command-line version.

$ npm install --save archive-type
var read = require('fs').readFileSync;
var archiveType = require('archive-type');
 
archiveType(read('foo.zip'));
//=> {ext: 'zip', mime: 'application/zip'} 

Returns 7z, bz2, gz, rar, tar, zip or false.

Type: buffer (Node.js), uint8array

It only needs the first 261 bytes.

MIT © Kevin Mårtensson