mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
contentType: Reply back proper contentTypes based on the file extension.
Currently the server would set 'application/octet-stream' for all objects, set this value based on the file extension transparently. This is useful in case of minio browser to facilitate displaying proper icons for the different mime data types.
This commit is contained in:
@@ -38,6 +38,7 @@ import (
|
||||
"github.com/minio/minio-xl/pkg/crypto/sha256"
|
||||
"github.com/minio/minio-xl/pkg/crypto/sha512"
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
"github.com/minio/minio/pkg/contentdb"
|
||||
"github.com/minio/minio/pkg/disk"
|
||||
)
|
||||
|
||||
@@ -432,12 +433,16 @@ func (fs Filesystem) CompleteMultipartUpload(bucket, object, uploadID string, da
|
||||
if err != nil {
|
||||
return ObjectMetadata{}, probe.NewError(err)
|
||||
}
|
||||
contentType := "application/octet-stream"
|
||||
if objectExt := filepath.Ext(objectPath); objectExt != "" {
|
||||
contentType = contentdb.MustLookup(strings.TrimPrefix(objectExt, "."))
|
||||
}
|
||||
newObject := ObjectMetadata{
|
||||
Bucket: bucket,
|
||||
Object: object,
|
||||
Created: st.ModTime(),
|
||||
Size: st.Size(),
|
||||
ContentType: "application/octet-stream",
|
||||
ContentType: contentType,
|
||||
Md5: hex.EncodeToString(h.Sum(nil)),
|
||||
}
|
||||
return newObject, nil
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/minio/minio-xl/pkg/atomic"
|
||||
"github.com/minio/minio-xl/pkg/crypto/sha256"
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
"github.com/minio/minio/pkg/contentdb"
|
||||
"github.com/minio/minio/pkg/disk"
|
||||
)
|
||||
|
||||
@@ -153,6 +154,9 @@ func getMetadata(rootPath, bucket, object string) (ObjectMetadata, *probe.Error)
|
||||
if runtime.GOOS == "windows" {
|
||||
object = sanitizeWindowsPath(object)
|
||||
}
|
||||
if objectExt := filepath.Ext(object); objectExt != "" {
|
||||
contentType = contentdb.MustLookup(strings.TrimPrefix(objectExt, "."))
|
||||
}
|
||||
metadata := ObjectMetadata{
|
||||
Bucket: bucket,
|
||||
Object: object,
|
||||
@@ -279,12 +283,16 @@ func (fs Filesystem) CreateObject(bucket, object, expectedMD5Sum string, size in
|
||||
if err != nil {
|
||||
return ObjectMetadata{}, probe.NewError(err)
|
||||
}
|
||||
contentType := "application/octet-stream"
|
||||
if objectExt := filepath.Ext(objectPath); objectExt != "" {
|
||||
contentType = contentdb.MustLookup(strings.TrimPrefix(objectExt, "."))
|
||||
}
|
||||
newObject := ObjectMetadata{
|
||||
Bucket: bucket,
|
||||
Object: object,
|
||||
Created: st.ModTime(),
|
||||
Size: st.Size(),
|
||||
ContentType: "application/octet-stream",
|
||||
ContentType: contentType,
|
||||
Md5: md5Sum,
|
||||
}
|
||||
return newObject, nil
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
"github.com/minio/minio/pkg/contentdb"
|
||||
)
|
||||
|
||||
// Filesystem - local variables
|
||||
@@ -79,6 +80,9 @@ func New(rootPath string) (Filesystem, *probe.Error) {
|
||||
return Filesystem{}, err.Trace()
|
||||
}
|
||||
}
|
||||
// Initialize content db.
|
||||
contentdb.Init()
|
||||
|
||||
var buckets *Buckets
|
||||
buckets, err = loadBucketsMetadata()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user