Simplify pkg mimedb (#6549)

Content-Type resolution can now use a function `TypeByExtension(extension)` 
to resolve to the respective content-type.
This commit is contained in:
Praveen raj Mani
2018-10-02 11:48:17 +05:30
committed by Nitish Tiwari
parent f163bed40d
commit c7722fbb1b
6 changed files with 54 additions and 34 deletions

View File

@@ -24,7 +24,6 @@ import (
"net/http"
"path"
"strconv"
"strings"
"sync"
"github.com/minio/minio/cmd/logger"
@@ -785,11 +784,7 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string,
// Guess content-type from the extension if possible.
if metadata["content-type"] == "" {
if objectExt := path.Ext(object); objectExt != "" {
if content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]; ok {
metadata["content-type"] = content.ContentType
}
}
metadata["content-type"] = mimedb.TypeByExtension(path.Ext(object))
}
if xl.isObject(bucket, object) {