Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendorize "github.com/minio/minio/pkg/mimedb" to use its content-type resolutions #2563

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/client-s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/json"
"hash/fnv"
"io"
"mime"
"net"
"net/http"
"net/url"
Expand All @@ -42,6 +41,7 @@ import (
"github.com/minio/minio-go/pkg/encrypt"
"github.com/minio/minio-go/pkg/policy"
"github.com/minio/minio-go/pkg/s3utils"
"github.com/minio/minio/pkg/mimedb"
)

// S3 client
Expand Down Expand Up @@ -396,8 +396,8 @@ var supportedContentTypes = []string{

func (c *s3Client) Select(expression, sseKey string) (io.ReadCloser, *probe.Error) {
bucket, object := c.url2BucketAndObject()
origContentType := mime.TypeByExtension(filepath.Ext(strings.TrimSuffix(strings.TrimSuffix(object, ".gz"), ".bz2")))
contentType := mime.TypeByExtension(filepath.Ext(object))
origContentType := mimedb.TypeByExtension(filepath.Ext(strings.TrimSuffix(strings.TrimSuffix(object, ".gz"), ".bz2")))
contentType := mimedb.TypeByExtension(filepath.Ext(object))
opts := minio.SelectObjectOptions{
Expression: expression,
ExpressionType: minio.QueryExpressionTypeSQL,
Expand Down
7 changes: 2 additions & 5 deletions cmd/client-url.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ package cmd

import (
"bytes"
"mime"
"path/filepath"
"regexp"
"runtime"
"strings"

"github.com/minio/mc/pkg/probe"
"github.com/minio/minio/pkg/mimedb"
)

// url client url structure
Expand Down Expand Up @@ -228,9 +228,6 @@ func isURLPrefixExists(urlPrefix string, incomplete bool) bool {
// on failure just return 'application/octet-stream'.
func guessURLContentType(urlStr string) string {
url := newClientURL(urlStr)
contentType := mime.TypeByExtension(filepath.Ext(url.Path))
if contentType == "" {
contentType = "application/octet-stream"
}
contentType := mimedb.TypeByExtension(filepath.Ext(url.Path))
return contentType
}
4 changes: 2 additions & 2 deletions cmd/select-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ package cmd

import (
"io"
"mime"
"os"
"path/filepath"
"strings"

"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio/pkg/mimedb"
)

var (
Expand Down Expand Up @@ -130,7 +130,7 @@ func mainSelect(ctx *cli.Context) error {
errorIf(content.Err.Trace(url), "Unable to list on target `"+url+"`.")
continue
}
contentType := mime.TypeByExtension(filepath.Ext(content.URL.Path))
contentType := mimedb.TypeByExtension(filepath.Ext(content.URL.Path))
for _, cTypeSuffix := range supportedContentTypes {
if strings.Contains(contentType, cTypeSuffix) {
errorIf(selectQl(targetAlias+content.URL.Path, ctx.String("expression"),
Expand Down
Loading