mmmagic / 0.3.9 last updated a year ago created on Apr 30th 2012
Install
npm install --save mmmagic
Clone
git clone git@github.com:mscdex/mmmagic.git
dependencies
No dependencies listed.
maintainers
versions
17 total
| 0.3.9 | a year ago | mscdex |
| 0.3.8 | a year ago | mscdex |
| 0.3.7 | 2 years ago | mscdex |
| 0.3.6 | 2 years ago | mscdex |
| 0.3.5 | 2 years ago | mscdex |
| 0.3.4 | 2 years ago | mscdex |
| 0.3.3 | 2 years ago | mscdex |
| 0.3.2 | 2 years ago | mscdex |
| 0.3.1 | 2 years ago | mscdex |
| 0.3.0 | 3 years ago | mscdex |
| 0.2.5 | 3 years ago | mscdex |
| 0.2.1 | 3 years ago | mscdex |
| 0.1.2 | 3 years ago | mscdex |
| 0.1.1 | 3 years ago | mscdex |
| 0.1.0 | 3 years ago | mscdex |
| 0.0.2 | 3 years ago | mscdex |
| 0.0.1 | 3 years ago | mscdex |
readme
Description
An async libmagic binding for node.js for detecting content types by data inspection.
Requirements
- node.js -- v0.6.0 or newer
Install
Examples
Get general description of a file:
Get mime type for a file:
Get mime type and mime encoding for a file:
Get general description of the contents of a Buffer:
API
Magic methods
(constructor)([< String >magicPath][, < Integer >flags]) - Creates and returns a new Magic instance. magicPath is an optional path string that points to a particular magic file to use. If magicPath is not a string and not false, the bundled magic file will be used. If magicPath is false, mmmagic will default to searching for a magic file to use (order of magic file searching:
MAGICenv var -> various file system paths (seeman file)). flags is a bitmask with the following valid values (available as constants on require('mmmagic')):- MAGIC_NONE - No flags set
- MAGIC_DEBUG - Turn on debugging
- MAGIC_SYMLINK - Follow symlinks (default for non-Windows)
- MAGIC_DEVICES - Look at the contents of devices
- MAGIC_MIME_TYPE - Return the MIME type
- MAGIC_CONTINUE - Return all matches
- MAGIC_CHECK - Print warnings to stderr
- MAGIC_PRESERVE_ATIME - Restore access time on exit
- MAGIC_RAW - Don't translate unprintable chars
- MAGIC_MIME_ENCODING - Return the MIME encoding
- MAGIC_MIME - (MAGIC_MIME_TYPE | MAGIC_MIME_ENCODING)
- MAGIC_APPLE - Return the Apple creator and type
- MAGIC_NO_CHECK_TAR - Don't check for tar files
- MAGIC_NO_CHECK_SOFT - Don't check magic entries
- MAGIC_NO_CHECK_APPTYPE - Don't check application type
- MAGIC_NO_CHECK_ELF - Don't check for elf details
- MAGIC_NO_CHECK_TEXT - Don't check for text files
- MAGIC_NO_CHECK_CDF - Don't check for cdf files
- MAGIC_NO_CHECK_TOKENS - Don't check tokens
- MAGIC_NO_CHECK_ENCODING - Don't check text encodings
detectFile(< String >path, < Function >callback) - (void) - Inspects the file pointed at by path. The callback receives two arguments: an < Error > object in case of error (null otherwise), and a < String > containing the result of the inspection.
detect(< Buffer >data, < Function >callback) - (void) - Inspects the contents of data. The callback receives two arguments: an < Error > object in case of error (null otherwise), and a < String > containing the result of the inspection.