Giter VIP home page Giter VIP logo

simplemagic's Introduction

This package provides some simple Java classes to read the magic files from Unix to simulate the file(1) command.

For more information, visit the home page:
	http://256.com/sources/simplemagic/

The git repository is:
	https://github.com/j256/simplemagic

Maven packages are published via the central repo:
	http://repo1.maven.org/maven2/com/j256/simplemagic/simplemagic/

Enjoy,
Gray Watson

----------------------------------------------------------------------

To get started you use the SimpleMagic package like the following:

    // create a magic utility using the internal magic file
    ContentInfoUtil util = new ContentInfoUtil();
    // if you want to use a different config file(s), you can load them by hand:
    // ContentInfoUtil util = new ContentInfoUtil("/etc/magic");
    ...
    ContentInfo info = util.findMatch("/tmp/upload.tmp");
    // or
    ContentInfo info = util.findMatch(inputStream);
    // or
    ContentInfo info = util.findMatch(contentByteArray);

Once you have the ContentDetails it provides:
 
    * Enumerated type if the type is common
    * Approximate content-name
    * Full message produced by the magic file
    * Mime-type string if one configured by the config file

For example:
    HTML, mime 'text/html', msg 'HTML document text'
    Java, msg 'Java serialization data, version 5'
    PDF, mime 'application/pdf', msg 'PDF document, version 1.4'
    gzip, mime 'application/x-gzip', msg 'gzip compressed data, was "", from Unix...'
    GIF, mime 'image/gif', msg 'GIF image data, version 89a, 16 x 16'
    PNG, mime 'image/png', msg 'PNG image, 600 x 371, 8-bit/color RGB, non-interlaced'
    ISO, mime 'audio/mp4', msg 'ISO Media, MPEG v4 system, iTunes AAC-LC'
    Microsoft, mime 'application/msword', msg 'Microsoft Word Document'
    RIFF, mime 'audio/x-wav', msg 'RIFF (little-endian) data, WAVE audio, Microsoft...'
    JPEG, mime 'image/jpeg', msg 'JPEG image data, JFIF standard 1.01'

simplemagic's People

Contributors

richid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.