Remove unnecessary GetObjectMetadata prefix argument

This commit is contained in:
Harshavardhana 2015-05-15 19:23:30 -07:00
parent 8ad52364da
commit 5c5761ae16
7 changed files with 43 additions and 44 deletions

View File

@ -49,7 +49,7 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
bucket = vars["bucket"] bucket = vars["bucket"]
object = vars["object"] object = vars["object"]
metadata, err := server.driver.GetObjectMetadata(bucket, object, "") metadata, err := server.driver.GetObjectMetadata(bucket, object)
switch err := iodine.ToError(err).(type) { switch err := iodine.ToError(err).(type) {
case nil: // success case nil: // success
{ {
@ -106,7 +106,7 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque
bucket = vars["bucket"] bucket = vars["bucket"]
object = vars["object"] object = vars["object"]
metadata, err := server.driver.GetObjectMetadata(bucket, object, "") metadata, err := server.driver.GetObjectMetadata(bucket, object)
switch err := iodine.ToError(err).(type) { switch err := iodine.ToError(err).(type) {
case nil: case nil:
{ {

View File

@ -158,9 +158,9 @@ func (s *MySuite) TestEmptyObject(c *C) {
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once() typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
typedDriver.On("CreateObject", "bucket", "object", "", "", 0, mock.Anything).Return(metadata.Md5, nil).Once() typedDriver.On("CreateObject", "bucket", "object", "", "", 0, mock.Anything).Return(metadata.Md5, nil).Once()
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Twice() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Twice()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(metadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(metadata, nil).Once()
typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(metadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(metadata, nil).Once()
httpHandler := HTTPHandler(driver) httpHandler := HTTPHandler(driver)
testServer := httptest.NewServer(httpHandler) testServer := httptest.NewServer(httpHandler)
defer testServer.Close() defer testServer.Close()
@ -182,7 +182,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes())) c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes()))
resMetadata, err := driver.GetObjectMetadata("bucket", "object", "") resMetadata, err := driver.GetObjectMetadata("bucket", "object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyHeaders(c, response.Header, resMetadata.Created, 0, "application/octet-stream", resMetadata.Md5) verifyHeaders(c, response.Header, resMetadata.Created, 0, "application/octet-stream", resMetadata.Md5)
} }
@ -240,7 +240,7 @@ func (s *MySuite) TestObject(c *C) {
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once() typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once()
typedDriver.On("CreateObject", "bucket", "object", "", "", mock.Anything, mock.Anything).Return(metadata.Md5, nil).Once() typedDriver.On("CreateObject", "bucket", "object", "", "", mock.Anything, mock.Anything).Return(metadata.Md5, nil).Once()
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Twice() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Twice()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(metadata, nil).Twice() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(metadata, nil).Twice()
typedDriver.SetGetObjectWriter("bucket", "object", []byte("hello world")) typedDriver.SetGetObjectWriter("bucket", "object", []byte("hello world"))
typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once()
@ -265,7 +265,7 @@ func (s *MySuite) TestObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(responseBody, DeepEquals, []byte("hello world")) c.Assert(responseBody, DeepEquals, []byte("hello world"))
resMetadata, err := driver.GetObjectMetadata("bucket", "object", "") resMetadata, err := driver.GetObjectMetadata("bucket", "object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyHeaders(c, response.Header, resMetadata.Created, len("hello world"), "application/octet-stream", metadata.Md5) verifyHeaders(c, response.Header, resMetadata.Created, len("hello world"), "application/octet-stream", metadata.Md5)
} }
@ -322,7 +322,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// test non-existant object // test non-existant object
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once()
request, err := http.NewRequest("GET", testServer.URL+"/bucket/object", nil) request, err := http.NewRequest("GET", testServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -336,7 +336,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// get object // get object
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object1", "").Return(metadata1, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object1").Return(metadata1, nil).Once()
typedDriver.SetGetObjectWriter("bucket", "object1", []byte("hello one")) typedDriver.SetGetObjectWriter("bucket", "object1", []byte("hello one"))
typedDriver.On("GetObject", mock.Anything, "bucket", "object1").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object1").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/object1", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/object1", nil)
@ -349,8 +349,8 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// get metadata // get metadata
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object1", "").Return(metadata1, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object1").Return(metadata1, nil).Once()
metadata, err := driver.GetObjectMetadata("bucket", "object1", "") metadata, err := driver.GetObjectMetadata("bucket", "object1")
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -366,7 +366,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// test object 2 // test object 2
// get object // get object
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object2", "").Return(metadata2, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object2").Return(metadata2, nil).Once()
typedDriver.SetGetObjectWriter("bucket", "object2", []byte("hello two")) typedDriver.SetGetObjectWriter("bucket", "object2", []byte("hello two"))
typedDriver.On("GetObject", mock.Anything, "bucket", "object2").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object2").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/object2", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/object2", nil)
@ -379,8 +379,8 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// get metadata // get metadata
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object2", "").Return(metadata2, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object2").Return(metadata2, nil).Once()
metadata, err = driver.GetObjectMetadata("bucket", "object2", "") metadata, err = driver.GetObjectMetadata("bucket", "object2")
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -396,7 +396,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// test object 3 // test object 3
// get object // get object
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object3", "").Return(metadata3, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object3").Return(metadata3, nil).Once()
typedDriver.SetGetObjectWriter("bucket", "object3", []byte("hello three")) typedDriver.SetGetObjectWriter("bucket", "object3", []byte("hello three"))
typedDriver.On("GetObject", mock.Anything, "bucket", "object3").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object3").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/object3", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/object3", nil)
@ -409,8 +409,8 @@ func (s *MySuite) TestMultipleObjects(c *C) {
// get metadata // get metadata
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object3", "").Return(metadata3, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object3").Return(metadata3, nil).Once()
metadata, err = driver.GetObjectMetadata("bucket", "object3", "") metadata, err = driver.GetObjectMetadata("bucket", "object3")
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -472,7 +472,7 @@ func (s *MySuite) TestHeader(c *C) {
ACL: drivers.BucketACL("private"), ACL: drivers.BucketACL("private"),
} }
typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once()
request, err := http.NewRequest("GET", testServer.URL+"/bucket/object", nil) request, err := http.NewRequest("GET", testServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -498,7 +498,7 @@ func (s *MySuite) TestHeader(c *C) {
driver.CreateObject("bucket", "object", "", "", int64(buffer.Len()), buffer) driver.CreateObject("bucket", "object", "", "", int64(buffer.Len()), buffer)
typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(objectMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(objectMetadata, nil).Once()
typedDriver.SetGetObjectWriter("", "", []byte("hello world")) typedDriver.SetGetObjectWriter("", "", []byte("hello world"))
typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/object", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/object", nil)
@ -511,8 +511,8 @@ func (s *MySuite) TestHeader(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(bucketMetadata, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "object", "").Return(objectMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "object").Return(objectMetadata, nil).Once()
metadata, err := driver.GetObjectMetadata("bucket", "object", "") metadata, err := driver.GetObjectMetadata("bucket", "object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyHeaders(c, response.Header, metadata.Created, len("hello world"), "application/octet-stream", metadata.Md5) verifyHeaders(c, response.Header, metadata.Created, len("hello world"), "application/octet-stream", metadata.Md5)
} }
@ -629,14 +629,14 @@ func (s *MySuite) TestPutObject(c *C) {
var writer bytes.Buffer var writer bytes.Buffer
typedDriver.On("GetObjectMetadata", "bucket", "two", "").Return(twoMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "two").Return(twoMetadata, nil).Once()
typedDriver.SetGetObjectWriter("bucket", "two", []byte("hello world")) typedDriver.SetGetObjectWriter("bucket", "two", []byte("hello world"))
typedDriver.On("GetObject", mock.Anything, "bucket", "two").Return(int64(11), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "two").Return(int64(11), nil).Once()
driver.GetObject(&writer, "bucket", "two") driver.GetObject(&writer, "bucket", "two")
c.Assert(bytes.Equal(writer.Bytes(), []byte("hello world")), Equals, true) c.Assert(bytes.Equal(writer.Bytes(), []byte("hello world")), Equals, true)
metadata, err := driver.GetObjectMetadata("bucket", "two", "") metadata, err := driver.GetObjectMetadata("bucket", "two")
c.Assert(err, IsNil) c.Assert(err, IsNil)
lastModified := metadata.Created lastModified := metadata.Created
@ -905,7 +905,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "one", "").Return(oneMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "one").Return(oneMetadata, nil).Once()
request, err = http.NewRequest("HEAD", testServer.URL+"/bucket/one", nil) request, err = http.NewRequest("HEAD", testServer.URL+"/bucket/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -917,7 +917,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
// test get object // test get object
typedDriver.SetGetObjectWriter("bucket", "once", []byte("")) typedDriver.SetGetObjectWriter("bucket", "once", []byte(""))
typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Twice() typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Twice()
typedDriver.On("GetObjectMetadata", "bucket", "one", "").Return(oneMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "one").Return(oneMetadata, nil).Once()
typedDriver.On("GetObject", mock.Anything, "bucket", "one").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "one").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/one", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -952,7 +952,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Once() typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Once()
typedDriver.On("GetObjectMetadata", "bucket", "two", "").Return(twoMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "two").Return(twoMetadata, nil).Once()
request, err = http.NewRequest("HEAD", testServer.URL+"/bucket/two", nil) request, err = http.NewRequest("HEAD", testServer.URL+"/bucket/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -963,7 +963,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
// test get object // test get object
typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Twice() typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Twice()
typedDriver.On("GetObjectMetadata", "bucket", "two", "").Return(twoMetadata, nil).Once() typedDriver.On("GetObjectMetadata", "bucket", "two").Return(twoMetadata, nil).Once()
typedDriver.On("GetObject", mock.Anything, "bucket", "two").Return(int64(0), nil).Once() typedDriver.On("GetObject", mock.Anything, "bucket", "two").Return(int64(0), nil).Once()
request, err = http.NewRequest("GET", testServer.URL+"/bucket/two", nil) request, err = http.NewRequest("GET", testServer.URL+"/bucket/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -1008,7 +1008,7 @@ func (s *MySuite) TestPartialContent(c *C) {
typedDriver.SetGetObjectWriter("foo", "bar", []byte("hello world")) typedDriver.SetGetObjectWriter("foo", "bar", []byte("hello world"))
typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "bar", "").Return(metadata, nil).Once() typedDriver.On("GetObjectMetadata", "foo", "bar").Return(metadata, nil).Once()
typedDriver.On("GetPartialObject", mock.Anything, "foo", "bar", int64(6), int64(2)).Return(int64(2), nil).Once() typedDriver.On("GetPartialObject", mock.Anything, "foo", "bar", int64(6), int64(2)).Return(int64(2), nil).Once()
// prepare request // prepare request
@ -1217,7 +1217,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
ACL: drivers.BucketACL("private"), ACL: drivers.BucketACL("private"),
} }
typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "bar", "").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once() typedDriver.On("GetObjectMetadata", "foo", "bar").Return(drivers.ObjectMetadata{}, drivers.ObjectNotFound{}).Once()
request, err := http.NewRequest("GET", testServer.URL+"/foo/bar", nil) request, err := http.NewRequest("GET", testServer.URL+"/foo/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -1236,7 +1236,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "bar", "").Return(drivers.ObjectMetadata{}, drivers.ObjectNameInvalid{}).Once() typedDriver.On("GetObjectMetadata", "foo", "bar").Return(drivers.ObjectMetadata{}, drivers.ObjectNameInvalid{}).Once()
request, err = http.NewRequest("GET", testServer.URL+"/foo/bar", nil) request, err = http.NewRequest("GET", testServer.URL+"/foo/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -1255,7 +1255,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest) verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(metadata, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "bar", "").Return(drivers.ObjectMetadata{}, drivers.BackendCorrupted{}).Once() typedDriver.On("GetObjectMetadata", "foo", "bar").Return(drivers.ObjectMetadata{}, drivers.BackendCorrupted{}).Once()
request, err = http.NewRequest("GET", testServer.URL+"/foo/bar", nil) request, err = http.NewRequest("GET", testServer.URL+"/foo/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -1295,7 +1295,7 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) {
} }
typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "bar", "").Return(metadata, nil).Once() typedDriver.On("GetObjectMetadata", "foo", "bar").Return(metadata, nil).Once()
request, err := http.NewRequest("GET", testServer.URL+"/foo/bar", nil) request, err := http.NewRequest("GET", testServer.URL+"/foo/bar", nil)
request.Header.Add("Range", "bytes=7-6") request.Header.Add("Range", "bytes=7-6")
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -1670,7 +1670,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
// get data // get data
typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once() typedDriver.On("GetBucketMetadata", "foo").Return(drivers.BucketMetadata{}, nil).Once()
typedDriver.On("GetObjectMetadata", "foo", "object", "").Return(drivers.ObjectMetadata{Size: 22}, nil).Once() typedDriver.On("GetObjectMetadata", "foo", "object").Return(drivers.ObjectMetadata{Size: 22}, nil).Once()
typedDriver.On("GetObject", mock.Anything, "foo", "object").Return(int64(22), nil).Once() typedDriver.On("GetObject", mock.Anything, "foo", "object").Return(int64(22), nil).Once()
typedDriver.SetGetObjectWriter("foo", "object", []byte("hello worldhello world")) typedDriver.SetGetObjectWriter("foo", "object", []byte("hello worldhello world"))
request, err = http.NewRequest("GET", testServer.URL+"/foo/object", nil) request, err = http.NewRequest("GET", testServer.URL+"/foo/object", nil)

View File

@ -157,7 +157,7 @@ func testMultipleObjectCreation(c *check.C, create func() Driver) {
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(byteBuffer.Bytes(), check.DeepEquals, value) c.Assert(byteBuffer.Bytes(), check.DeepEquals, value)
metadata, err := drivers.GetObjectMetadata("bucket", key, "") metadata, err := drivers.GetObjectMetadata("bucket", key)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(metadata.Size, check.Equals, int64(len(value))) c.Assert(metadata.Size, check.Equals, int64(len(value)))
@ -490,19 +490,19 @@ func testDefaultContentType(c *check.C, create func() Driver) {
// test empty // test empty
_, err = drivers.CreateObject("bucket", "one", "", "", int64(len("one")), bytes.NewBufferString("one")) _, err = drivers.CreateObject("bucket", "one", "", "", int64(len("one")), bytes.NewBufferString("one"))
metadata, err := drivers.GetObjectMetadata("bucket", "one", "") metadata, err := drivers.GetObjectMetadata("bucket", "one")
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(metadata.ContentType, check.Equals, "application/octet-stream") c.Assert(metadata.ContentType, check.Equals, "application/octet-stream")
// test custom // test custom
drivers.CreateObject("bucket", "two", "application/text", "", int64(len("two")), bytes.NewBufferString("two")) drivers.CreateObject("bucket", "two", "application/text", "", int64(len("two")), bytes.NewBufferString("two"))
metadata, err = drivers.GetObjectMetadata("bucket", "two", "") metadata, err = drivers.GetObjectMetadata("bucket", "two")
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(metadata.ContentType, check.Equals, "application/text") c.Assert(metadata.ContentType, check.Equals, "application/text")
// test trim space // test trim space
drivers.CreateObject("bucket", "three", "\tapplication/json ", "", int64(len("three")), bytes.NewBufferString("three")) drivers.CreateObject("bucket", "three", "\tapplication/json ", "", int64(len("three")), bytes.NewBufferString("three"))
metadata, err = drivers.GetObjectMetadata("bucket", "three", "") metadata, err = drivers.GetObjectMetadata("bucket", "three")
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(metadata.ContentType, check.Equals, "application/json") c.Assert(metadata.ContentType, check.Equals, "application/json")
} }

View File

@ -275,11 +275,10 @@ func (d donutDriver) GetPartialObject(w io.Writer, bucketName, objectName string
} }
// GetObjectMetadata retrieves an object's metadata // GetObjectMetadata retrieves an object's metadata
func (d donutDriver) GetObjectMetadata(bucketName, objectName, prefixName string) (drivers.ObjectMetadata, error) { func (d donutDriver) GetObjectMetadata(bucketName, objectName string) (drivers.ObjectMetadata, error) {
errParams := map[string]string{ errParams := map[string]string{
"bucketName": bucketName, "bucketName": bucketName,
"objectName": objectName, "objectName": objectName,
"prefixName": prefixName,
} }
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil) return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil)

View File

@ -35,7 +35,7 @@ type Driver interface {
// Object Operations // Object Operations
GetObject(w io.Writer, bucket, object string) (int64, error) GetObject(w io.Writer, bucket, object string) (int64, error)
GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error)
GetObjectMetadata(bucket, key, prefix string) (ObjectMetadata, error) GetObjectMetadata(bucket, key string) (ObjectMetadata, error)
ListObjects(bucket string, resources BucketResourcesMetadata) ([]ObjectMetadata, BucketResourcesMetadata, error) ListObjects(bucket string, resources BucketResourcesMetadata) ([]ObjectMetadata, BucketResourcesMetadata, error)
CreateObject(bucket, key, contentType, md5sum string, size int64, data io.Reader) (string, error) CreateObject(bucket, key, contentType, md5sum string, size int64, data io.Reader) (string, error)

View File

@ -478,14 +478,14 @@ func (memory *memoryDriver) ListBuckets() ([]drivers.BucketMetadata, error) {
} }
// GetObjectMetadata - get object metadata from memory // GetObjectMetadata - get object metadata from memory
func (memory *memoryDriver) GetObjectMetadata(bucket, key, prefix string) (drivers.ObjectMetadata, error) { func (memory *memoryDriver) GetObjectMetadata(bucket, key string) (drivers.ObjectMetadata, error) {
memory.lock.RLock() memory.lock.RLock()
defer memory.lock.RUnlock() defer memory.lock.RUnlock()
// check if bucket exists // check if bucket exists
if !drivers.IsValidBucket(bucket) { if !drivers.IsValidBucket(bucket) {
return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
} }
if !drivers.IsValidObjectName(key) || !drivers.IsValidObjectName(prefix) { if !drivers.IsValidObjectName(key) {
return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: key}, nil) return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: key}, nil)
} }
if _, ok := memory.storedBuckets[bucket]; ok == false { if _, ok := memory.storedBuckets[bucket]; ok == false {

View File

@ -97,8 +97,8 @@ func (m *Driver) GetPartialObject(w io.Writer, bucket, object string, start int6
} }
// GetObjectMetadata is a mock // GetObjectMetadata is a mock
func (m *Driver) GetObjectMetadata(bucket, object, prefix string) (drivers.ObjectMetadata, error) { func (m *Driver) GetObjectMetadata(bucket, object string) (drivers.ObjectMetadata, error) {
ret := m.Called(bucket, object, prefix) ret := m.Called(bucket, object)
r0 := ret.Get(0).(drivers.ObjectMetadata) r0 := ret.Get(0).(drivers.ObjectMetadata)
r1 := ret.Error(1) r1 := ret.Error(1)