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
+5 -3
View File
@@ -225,13 +225,15 @@ func (fs fsObjects) GetObjectInfo(bucket, object string) (ObjectInfo, error) {
if err != nil {
return ObjectInfo{}, toObjectErr(err, bucket, object)
}
contentType := "application/octet-stream"
// Guess content-type from the extension if possible.
contentType := ""
if objectExt := filepath.Ext(object); objectExt != "" {
content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]
if ok {
if content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]; ok {
contentType = content.ContentType
}
}
return ObjectInfo{
Bucket: bucket,
Name: object,