archive-type

Detect the archive type of a Buffer/Uint8Array

archive-type

Detect the archive type of a Buffer/Uint8Array

$ 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.

$ npm install --global archive-type
$ archive-type --help
 
  Usage
    $ archive-type <file>
    $ cat <file> | archive-type
 
  Example
    $ archive-type foo.tar.gz
    $ cat foo.tar.gz | archive-type

MIT © Kevin Mårtensson