File: README.md

package info (click to toggle)
golang-github-vimeo-go-magic 1.0.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 72 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# go-magic #

## Go library for getting MIME type using libmagic ##

### Installing ###

```
go get github.com/vimeo/go-magic/magic
```

### Dependencies ###

**libmagic**<br />
*URL*: [http://www.darwinsys.com/file/](http://www.darwinsys.com/file/)<br />
*Ubuntu*: `apt-get install libmagic-dev`<br />
*CentOS*: `yum install file-devel`<br />

### Usage ###

- Create some custom magic files (e.g. ~/magicfiles)
- Add the default system magic file dir
    - magic.AddMagicDir(magic.GetDefaultDir())
- Add the custom magic file dir
    - magic.AddMagicDir("~/magicfiles")
- Get MIME type with either one of:
    - magic.MimeFromFile(filename)
    - magic.MimeFromBytes(data)

### API Documentation ###

[http://godoc.org/github.com/vimeo/go-magic/magic](http://godoc.org/github.com/vimeo/go-magic/magic)