mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
Adding GetObjectMetadata to donut
This commit is contained in:
parent
703af6c3ce
commit
99cf484488
@ -10,7 +10,7 @@ type Donut interface {
|
||||
ListBuckets() ([]string, error)
|
||||
GetObjectWriter(bucket, object string) (ObjectWriter, error)
|
||||
GetObject(bucket, object string) (io.ReadCloser, error)
|
||||
// GetObjectMetadata(bucket, object string) (map[string]string, error)
|
||||
GetObjectMetadata(bucket, object string) (map[string]string, error)
|
||||
// GetObjectWriter(bucket, object string) (ObjectWriter, error)
|
||||
// ListObjects(bucket string) ([]string, error)
|
||||
}
|
||||
|
@ -113,6 +113,21 @@ func (driver donutDriver) GetObject(bucketName, objectName string) (io.ReadClose
|
||||
return nil, errors.New("Bucket not found")
|
||||
}
|
||||
|
||||
// GetObjectMetadata returns metadata for a given object in a bucket
|
||||
func (driver donutDriver) GetObjectMetadata(bucketName, object string) (map[string]string, error) {
|
||||
if bucket, ok := driver.buckets[bucketName]; ok {
|
||||
nodes, err := bucket.GetNodes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if node, ok := driver.nodes[nodes[0]]; ok {
|
||||
return node.GetMetadata(bucketName+":0:0", object)
|
||||
}
|
||||
return nil, errors.New("Cannot connect to node: " + nodes[0])
|
||||
}
|
||||
return nil, errors.New("Bucket not found")
|
||||
}
|
||||
|
||||
func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, writer *io.PipeWriter) {
|
||||
totalChunks, _ := strconv.Atoi(donutMetadata["chunkCount"])
|
||||
totalLeft, _ := strconv.Atoi(donutMetadata["totalLength"])
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
. "gopkg.in/check.v1"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -159,6 +160,11 @@ func (s *MySuite) TestNewObjectCanBeWritten(c *C) {
|
||||
_, err = io.Copy(&actualData, reader)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(actualData.Bytes(), DeepEquals, []byte(data))
|
||||
|
||||
actualMetadata, err := donut.GetObjectMetadata("foo", "obj")
|
||||
c.Assert(err, IsNil)
|
||||
log.Println(actualMetadata)
|
||||
c.Assert(actualMetadata, DeepEquals, expectedMetadata)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestMultipleNewObjects(c *C) {
|
||||
|
Loading…
Reference in New Issue
Block a user