Skip to content
Permalink
Browse files

Added package gabriel-vasile/mimetype for better mime type detection

  • Loading branch information...
eko committed May 14, 2019
1 parent fc1b508 commit 35b6e8a8c7645ba82967287d56df423236956b3f
Showing with 39 additions and 20 deletions.
  1. +18 −16 Gopkg.lock
  2. +4 −0 Gopkg.toml
  3. +2 −3 go.mod
  4. +10 −0 go.sum
  5. +5 −1 middleware.go

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -2,6 +2,10 @@
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/gabriel-vasile/mimetype"
version = "0.3.7"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.3.0"
5 go.mod
@@ -1,8 +1,7 @@
module github.com/eko/graphql-go-upload

require (
github.com/davecgh/go-spew v1.1.1
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/objx v0.1.1
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v0.3.7
github.com/stretchr/testify v1.3.0
)
10 go.sum
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v0.3.7 h1:CgMynyHCbDm+sM9KU3M6KIlYaI86TtCg70Ai7OP2bIA=
github.com/gabriel-vasile/mimetype v0.3.7/go.mod h1:kMJbg3SlWZCsj4R73F1WDzbT9AyGCOVmUtIxxwO5pmI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -12,6 +12,8 @@ import (
"path/filepath"
"strings"
"sync"

"github.com/gabriel-vasile/mimetype"
)

type postedFiles func(key string) (multipart.File, *multipart.FileHeader, error)
@@ -216,5 +218,7 @@ func getMimeType(file multipart.File) (string, error) {
return "", err
}

return http.DetectContentType(buffer[:n]), nil
mimeType, _ := mimetype.Detect(buffer[:n])

return mimeType, nil
}

0 comments on commit 35b6e8a

Please sign in to comment.
You can’t perform that action at this time.