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

This commit is contained in:
Anand Babu (AB) Periasamy authored and Harshavardhana committed 2016-06-17 10:12:02 +05:30
1 parent 129ebbd685
commit f51d34cedd
4 files changed
+24 -25

No files matched your search

+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,