mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
parent
2f05aacbf2
commit
13e4618309
@ -231,7 +231,9 @@ func getMultipartObjectInfo(storage StorageAPI, bucket, object string) (info Mul
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return ObjectInfo.
|
// Return ObjectInfo.
|
||||||
func (xl xlObjects) getObjectInfo(bucket, object string) (ObjectInfo, error) {
|
func (xl xlObjects) getObjectInfo(bucket, object string) (objInfo ObjectInfo, err error) {
|
||||||
|
objInfo.Bucket = bucket
|
||||||
|
objInfo.Name = object
|
||||||
// First see if the object was a simple-PUT upload.
|
// First see if the object was a simple-PUT upload.
|
||||||
fi, err := xl.storage.StatFile(bucket, object)
|
fi, err := xl.storage.StatFile(bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -244,26 +246,38 @@ func (xl xlObjects) getObjectInfo(bucket, object string) (ObjectInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ObjectInfo{}, err
|
return ObjectInfo{}, err
|
||||||
}
|
}
|
||||||
fi.Size = info.Size
|
objInfo.Size = info.Size
|
||||||
fi.ModTime = info.ModTime
|
objInfo.ModTime = info.ModTime
|
||||||
fi.MD5Sum = info.MD5Sum
|
objInfo.MD5Sum = info.MD5Sum
|
||||||
}
|
objInfo.ContentType = info.ContentType
|
||||||
contentType := "application/octet-stream"
|
} else {
|
||||||
if objectExt := filepath.Ext(object); objectExt != "" {
|
metadata := make(map[string]string)
|
||||||
content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]
|
offset := int64(0) // To read entire content
|
||||||
if ok {
|
r, err := xl.storage.ReadFile(bucket, pathJoin(object, "meta.json"), offset)
|
||||||
contentType = content.ContentType
|
if err != nil {
|
||||||
|
return ObjectInfo{}, toObjectErr(err, bucket, object)
|
||||||
}
|
}
|
||||||
|
decoder := json.NewDecoder(r)
|
||||||
|
if err = decoder.Decode(&metadata); err != nil {
|
||||||
|
return ObjectInfo{}, toObjectErr(err, bucket, object)
|
||||||
|
}
|
||||||
|
contentType := metadata["content-type"]
|
||||||
|
if len(contentType) == 0 {
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
if objectExt := filepath.Ext(object); objectExt != "" {
|
||||||
|
content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]
|
||||||
|
if ok {
|
||||||
|
contentType = content.ContentType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
objInfo.Size = fi.Size
|
||||||
|
objInfo.IsDir = fi.Mode.IsDir()
|
||||||
|
objInfo.ModTime = fi.ModTime
|
||||||
|
objInfo.MD5Sum = metadata["md5Sum"]
|
||||||
|
objInfo.ContentType = contentType
|
||||||
}
|
}
|
||||||
return ObjectInfo{
|
return objInfo, nil
|
||||||
Bucket: bucket,
|
|
||||||
Name: object,
|
|
||||||
ModTime: fi.ModTime,
|
|
||||||
Size: fi.Size,
|
|
||||||
IsDir: fi.Mode.IsDir(),
|
|
||||||
ContentType: contentType,
|
|
||||||
MD5Sum: fi.MD5Sum,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetObjectInfo - get object info.
|
// GetObjectInfo - get object info.
|
||||||
|
Loading…
Reference in New Issue
Block a user