Do not guess content-type for objects with no extension (#1918)

This commit is contained in:
Anand Babu (AB) Periasamy
2016-06-16 21:42:02 -07:00
committed by Harshavardhana
parent 129ebbd685
commit f51d34cedd
4 changed files with 24 additions and 25 deletions
+3 -6
View File
@@ -312,16 +312,13 @@ func (xl xlObjects) PutObject(bucket string, object string, size int64, data io.
metadata["md5Sum"] = newMD5Hex
}
// If not set default to "application/octet-stream"
// Guess content-type from the extension if possible.
if metadata["content-type"] == "" {
contentType := "application/octet-stream"
if objectExt := filepath.Ext(object); objectExt != "" {
content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]
if ok {
contentType = content.ContentType
if content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]; ok {
metadata["content-type"] = content.ContentType
}
}
metadata["content-type"] = contentType
}
// md5Hex representation.