Skip to content

Commit

Permalink
Merge 8acf2e4 into 03d6157
Browse files Browse the repository at this point in the history
  • Loading branch information
Arimeka committed Jul 3, 2020
2 parents 03d6157 + 8acf2e4 commit dc519c0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"github.com/rakyll/magicmime"
)

// CalculateMime calculates mime type by magic numbers
// Function uses libmagic bindings using github.com/rakyll/magicmime package.
func (info *Info) CalculateMime() (err error) {
func init() {
if err := magicmime.Open(magicmime.MAGIC_MIME_TYPE | magicmime.MAGIC_SYMLINK | magicmime.MAGIC_ERROR); err != nil {
return err
panic(err)
}
defer magicmime.Close()
}

// CalculateMime calculates mime type by magic numbers
// Function uses libmagic bindings using github.com/rakyll/magicmime package.
func (info *Info) CalculateMime() (err error) {
var media string
if info.data != nil {
media, err = magicmime.TypeByBuffer(info.data)
Expand Down

0 comments on commit dc519c0

Please sign in to comment.