2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00
2015-09-24 10:40:41 +01:00

filetype Build Status GoDoc

Small Go package to infer the file type checking the magic number of a given binary buffer.

Supports a wide range of file types, including images formats, fonts, videos, audio and other common application files, and provides the proper file extension and convenient MIME code.

Installation

go get gopkg.in/h2non/filetype.v0

Usage

import (
  "fmt"
  "io/ioutil"
  "gopkg.in/h2non/filetype.v0"
)

func main() {
  buf, _ := ioutil.ReadFile("sample.jpg")

  kind, unkwown := filetype.Type(buf)
  if unkwown != nil {
    fmt.Printf("Unkwown file type")
    return
  }

  fmt.Printf("File type found: %s. MIME: %s", kind.Extension, kind.MIME.Value)
}

API

License

MIT - Tomas Aparicio

S
Description
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature
Readme MIT 12 MiB
Languages
Go 100%