Merge pull request #287 from harshavardhana/pr_out_restructure_and_use_human_readable_names

This commit is contained in:
Harshavardhana 2015-03-12 00:38:19 -07:00
commit 9889796c9c
10 changed files with 65 additions and 60 deletions

View File

@ -61,7 +61,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
buffer := bytes.NewBufferString("") buffer := bytes.NewBufferString("")
storage.CreateBucket("bucket") storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer) storage.CreateObject("bucket", "object", "", buffer)
response, err := http.Get(testServer.URL + "/bucket/object") response, err := http.Get(testServer.URL + "/bucket/object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -86,7 +86,7 @@ func (s *MySuite) TestObject(c *C) {
buffer := bytes.NewBufferString("hello world") buffer := bytes.NewBufferString("hello world")
storage.CreateBucket("bucket") storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer) storage.CreateObject("bucket", "object", "", buffer)
response, err := http.Get(testServer.URL + "/bucket/object") response, err := http.Get(testServer.URL + "/bucket/object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -112,9 +112,9 @@ func (s *MySuite) TestMultipleObjects(c *C) {
buffer3 := bytes.NewBufferString("hello three") buffer3 := bytes.NewBufferString("hello three")
storage.CreateBucket("bucket") storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object1", "", buffer1) storage.CreateObject("bucket", "object1", "", buffer1)
storage.StoreObject("bucket", "object2", "", buffer2) storage.CreateObject("bucket", "object2", "", buffer2)
storage.StoreObject("bucket", "object3", "", buffer3) storage.CreateObject("bucket", "object3", "", buffer3)
// test non-existant object // test non-existant object
response, err := http.Get(testServer.URL + "/bucket/object") response, err := http.Get(testServer.URL + "/bucket/object")
@ -204,7 +204,7 @@ func (s *MySuite) TestHeader(c *C) {
buffer := bytes.NewBufferString("hello world") buffer := bytes.NewBufferString("hello world")
storage.CreateBucket("bucket") storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer) storage.CreateObject("bucket", "object", "", buffer)
response, err = http.Get(testServer.URL + "/bucket/object") response, err = http.Get(testServer.URL + "/bucket/object")
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -285,7 +285,7 @@ func (s *MySuite) TestPutObject(c *C) {
var writer bytes.Buffer var writer bytes.Buffer
storage.CopyObjectToWriter(&writer, "bucket", "two") storage.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)

View File

@ -52,7 +52,7 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
switch httpRange.start == 0 && httpRange.length == 0 { switch httpRange.start == 0 && httpRange.length == 0 {
case true: case true:
writeObjectHeaders(w, metadata) writeObjectHeaders(w, metadata)
if _, err := server.storage.CopyObjectToWriter(w, bucket, object); err != nil { if _, err := server.storage.GetObject(w, bucket, object); err != nil {
log.Println(err) log.Println(err)
error := errorCodeError(InternalError) error := errorCodeError(InternalError)
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object) errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
@ -64,7 +64,7 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
metadata.Size = httpRange.length metadata.Size = httpRange.length
writeRangeObjectHeaders(w, metadata, httpRange.getContentRange()) writeRangeObjectHeaders(w, metadata, httpRange.getContentRange())
w.WriteHeader(http.StatusPartialContent) w.WriteHeader(http.StatusPartialContent)
_, err := server.storage.CopyObjectToWriterRange(w, bucket, object, httpRange.start, httpRange.length) _, err := server.storage.GetPartialObject(w, bucket, object, httpRange.start, httpRange.length)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
error := errorCodeError(InternalError) error := errorCodeError(InternalError)
@ -165,7 +165,7 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques
return return
} }
err := server.storage.StoreObject(bucket, object, "", req.Body) err := server.storage.CreateObject(bucket, object, "", req.Body)
switch err := err.(type) { switch err := err.(type) {
case nil: case nil:
w.Header().Set("Server", "Minio") w.Header().Set("Server", "Minio")

View File

@ -43,7 +43,7 @@ func (server *minioAPI) putBucketPolicyHandler(w http.ResponseWriter, req *http.
return return
} }
err := server.storage.StoreBucketPolicy(bucket, policy) err := server.storage.CreateBucketPolicy(bucket, policy)
switch err := err.(type) { switch err := err.(type) {
case nil: case nil:
{ {

View File

@ -31,8 +31,8 @@ import (
/// Object Operations /// Object Operations
// CopyObjectToWriterRange - GET object from range // GetPartialObject - GET object from range
func (storage *Storage) CopyObjectToWriterRange(w io.Writer, bucket, object string, start, length int64) (int64, error) { func (storage *Storage) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error) {
// validate bucket // validate bucket
if mstorage.IsValidBucket(bucket) == false { if mstorage.IsValidBucket(bucket) == false {
return 0, mstorage.BucketNameInvalid{Bucket: bucket} return 0, mstorage.BucketNameInvalid{Bucket: bucket}
@ -79,8 +79,8 @@ func (storage *Storage) CopyObjectToWriterRange(w io.Writer, bucket, object stri
return count, nil return count, nil
} }
// CopyObjectToWriter - GET object // GetObject - GET object from key
func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) { func (storage *Storage) GetObject(w io.Writer, bucket string, object string) (int64, error) {
// validate bucket // validate bucket
if mstorage.IsValidBucket(bucket) == false { if mstorage.IsValidBucket(bucket) == false {
return 0, mstorage.BucketNameInvalid{Bucket: bucket} return 0, mstorage.BucketNameInvalid{Bucket: bucket}
@ -181,8 +181,8 @@ func (storage *Storage) GetObjectMetadata(bucket, object, prefix string) (mstora
return metadata, nil return metadata, nil
} }
// StoreObject - PUT object // CreateObject - PUT object
func (storage *Storage) StoreObject(bucket, key, contentType string, data io.Reader) error { func (storage *Storage) CreateObject(bucket, key, contentType string, data io.Reader) error {
// TODO Commits should stage then move instead of writing directly // TODO Commits should stage then move instead of writing directly
storage.lock.Lock() storage.lock.Lock()
defer storage.lock.Unlock() defer storage.lock.Unlock()

View File

@ -69,8 +69,8 @@ func (storage *Storage) GetBucketPolicy(bucket string) (mstorage.BucketPolicy, e
} }
// StoreBucketPolicy - PUT bucket policy // CreateBucketPolicy - PUT bucket policy
func (storage *Storage) StoreBucketPolicy(bucket string, p mstorage.BucketPolicy) error { func (storage *Storage) CreateBucketPolicy(bucket string, p mstorage.BucketPolicy) error {
storage.lock.Lock() storage.lock.Lock()
defer storage.lock.Unlock() defer storage.lock.Unlock()

View File

@ -64,8 +64,8 @@ func start(ctrlChannel <-chan string, errorChannel chan<- error) {
close(errorChannel) close(errorChannel)
} }
// CopyObjectToWriter - GET object from memory buffer // GetObject - GET object from memory buffer
func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) { func (storage *Storage) GetObject(w io.Writer, bucket string, object string) (int64, error) {
// get object // get object
key := object key := object
if val, ok := storage.objectdata[key]; ok { if val, ok := storage.objectdata[key]; ok {
@ -76,13 +76,13 @@ func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object st
return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object} return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object}
} }
// CopyObjectToWriterRange - GET object from memory buffer range // GetPartialObject - GET object from memory buffer range
func (storage *Storage) CopyObjectToWriterRange(w io.Writer, bucket, object string, start, end int64) (int64, error) { func (storage *Storage) GetPartialObject(w io.Writer, bucket, object string, start, end int64) (int64, error) {
return 0, mstorage.APINotImplemented{API: "GetObjectRange"} return 0, mstorage.APINotImplemented{API: "GetPartialObject"}
} }
// StoreBucketPolicy - Not implemented // CreateBucketPolicy - Not implemented
func (storage *Storage) StoreBucketPolicy(bucket string, policy mstorage.BucketPolicy) error { func (storage *Storage) CreateBucketPolicy(bucket string, policy mstorage.BucketPolicy) error {
return mstorage.APINotImplemented{API: "PutBucketPolicy"} return mstorage.APINotImplemented{API: "PutBucketPolicy"}
} }
@ -91,8 +91,8 @@ func (storage *Storage) GetBucketPolicy(bucket string) (mstorage.BucketPolicy, e
return mstorage.BucketPolicy{}, mstorage.APINotImplemented{API: "GetBucketPolicy"} return mstorage.BucketPolicy{}, mstorage.APINotImplemented{API: "GetBucketPolicy"}
} }
// StoreObject - PUT object to memory buffer // CreateObject - PUT object to memory buffer
func (storage *Storage) StoreObject(bucket, key, contentType string, data io.Reader) error { func (storage *Storage) CreateObject(bucket, key, contentType string, data io.Reader) error {
storage.lock.Lock() storage.lock.Lock()
defer storage.lock.Unlock() defer storage.lock.Unlock()

View File

@ -53,8 +53,8 @@ func (diskStorage StorageDriver) CreateBucket(bucket string) error {
return errors.New("Not Implemented") return errors.New("Not Implemented")
} }
// StoreBucketPolicy sets a bucket's access policy // CreateBucketPolicy sets a bucket's access policy
func (diskStorage StorageDriver) StoreBucketPolicy(bucket string, p storage.BucketPolicy) error { func (diskStorage StorageDriver) CreateBucketPolicy(bucket string, p storage.BucketPolicy) error {
return errors.New("Not Implemented") return errors.New("Not Implemented")
} }
@ -63,13 +63,18 @@ func (diskStorage StorageDriver) GetBucketPolicy(bucket string) (storage.BucketP
return storage.BucketPolicy{}, errors.New("Not Implemented") return storage.BucketPolicy{}, errors.New("Not Implemented")
} }
// CopyObjectToWriter retrieves an object and writes it to a writer // GetObject retrieves an object and writes it to a writer
func (diskStorage StorageDriver) CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) { func (diskStorage StorageDriver) GetObject(w io.Writer, bucket, object string) (int64, error) {
return 0, errors.New("Not Implemented")
}
// GetPartialObject retrieves an object and writes it to a writer
func (diskStorage StorageDriver) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error) {
return 0, errors.New("Not Implemented") return 0, errors.New("Not Implemented")
} }
// GetObjectMetadata retrieves an object's metadata // GetObjectMetadata retrieves an object's metadata
func (diskStorage StorageDriver) GetObjectMetadata(bucket string, object string, prefix string) (storage.ObjectMetadata, error) { func (diskStorage StorageDriver) GetObjectMetadata(bucket, object string, prefix string) (storage.ObjectMetadata, error) {
return storage.ObjectMetadata{}, errors.New("Not Implemented") return storage.ObjectMetadata{}, errors.New("Not Implemented")
} }
@ -78,7 +83,7 @@ func (diskStorage StorageDriver) ListObjects(bucket string, resources storage.Bu
return nil, storage.BucketResourcesMetadata{}, errors.New("Not Implemented") return nil, storage.BucketResourcesMetadata{}, errors.New("Not Implemented")
} }
// StoreObject creates a new object // CreateObject creates a new object
func (diskStorage StorageDriver) StoreObject(bucket string, key string, contentType string, data io.Reader) error { func (diskStorage StorageDriver) CreateObject(bucket string, key string, contentType string, data io.Reader) error {
return errors.New("Not Implemented") return errors.New("Not Implemented")
} }

View File

@ -28,15 +28,15 @@ type Storage interface {
// Bucket Operations // Bucket Operations
ListBuckets() ([]BucketMetadata, error) ListBuckets() ([]BucketMetadata, error)
CreateBucket(bucket string) error CreateBucket(bucket string) error
StoreBucketPolicy(bucket string, p BucketPolicy) error CreateBucketPolicy(bucket string, p BucketPolicy) error
GetBucketPolicy(bucket string) (BucketPolicy, error) GetBucketPolicy(bucket string) (BucketPolicy, error)
// Object Operations // Object Operations
CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) GetObject(w io.Writer, bucket, object string) (int64, error)
CopyObjectToWriterRange(w io.Writer, bucket string, object string, start, length int64) (int64, error) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error)
GetObjectMetadata(bucket string, object string, prefix string) (ObjectMetadata, error) GetObjectMetadata(bucket string, object string, prefix string) (ObjectMetadata, error)
ListObjects(bucket string, resources BucketResourcesMetadata) ([]ObjectMetadata, BucketResourcesMetadata, error) ListObjects(bucket string, resources BucketResourcesMetadata) ([]ObjectMetadata, BucketResourcesMetadata, error)
StoreObject(bucket string, key string, contentType string, data io.Reader) error CreateObject(bucket string, key string, contentType string, data io.Reader) error
} }
// BucketMetadata - name and create date // BucketMetadata - name and create date

View File

@ -58,7 +58,7 @@ func testMultipleObjectCreation(c *check.C, create func() Storage) {
} }
key := "obj" + strconv.Itoa(i) key := "obj" + strconv.Itoa(i)
objects[key] = []byte(randomString) objects[key] = []byte(randomString)
err := storage.StoreObject("bucket", key, "", bytes.NewBufferString(randomString)) err := storage.CreateObject("bucket", key, "", bytes.NewBufferString(randomString))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
} }
@ -66,7 +66,7 @@ func testMultipleObjectCreation(c *check.C, create func() Storage) {
etags := make(map[string]string) etags := make(map[string]string)
for key, value := range objects { for key, value := range objects {
var byteBuffer bytes.Buffer var byteBuffer bytes.Buffer
storage.CopyObjectToWriter(&byteBuffer, "bucket", key) storage.GetObject(&byteBuffer, "bucket", key)
c.Assert(bytes.Equal(value, byteBuffer.Bytes()), check.Equals, true) c.Assert(bytes.Equal(value, byteBuffer.Bytes()), check.Equals, true)
metadata, err := storage.GetObjectMetadata("bucket", key, "") metadata, err := storage.GetObjectMetadata("bucket", key, "")
@ -90,7 +90,7 @@ func testPaging(c *check.C, create func() Storage) {
// check before paging occurs // check before paging occurs
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
key := "obj" + strconv.Itoa(i) key := "obj" + strconv.Itoa(i)
storage.StoreObject("bucket", key, "", bytes.NewBufferString(key)) storage.CreateObject("bucket", key, "", bytes.NewBufferString(key))
resources.Maxkeys = 5 resources.Maxkeys = 5
objects, resources, err = storage.ListObjects("bucket", resources) objects, resources, err = storage.ListObjects("bucket", resources)
c.Assert(len(objects), check.Equals, i+1) c.Assert(len(objects), check.Equals, i+1)
@ -100,7 +100,7 @@ func testPaging(c *check.C, create func() Storage) {
// check after paging occurs pages work // check after paging occurs pages work
for i := 6; i <= 10; i++ { for i := 6; i <= 10; i++ {
key := "obj" + strconv.Itoa(i) key := "obj" + strconv.Itoa(i)
storage.StoreObject("bucket", key, "", bytes.NewBufferString(key)) storage.CreateObject("bucket", key, "", bytes.NewBufferString(key))
resources.Maxkeys = 5 resources.Maxkeys = 5
objects, resources, err = storage.ListObjects("bucket", resources) objects, resources, err = storage.ListObjects("bucket", resources)
c.Assert(len(objects), check.Equals, 5) c.Assert(len(objects), check.Equals, 5)
@ -109,8 +109,8 @@ func testPaging(c *check.C, create func() Storage) {
} }
// check paging with prefix at end returns less objects // check paging with prefix at end returns less objects
{ {
storage.StoreObject("bucket", "newPrefix", "", bytes.NewBufferString("prefix1")) storage.CreateObject("bucket", "newPrefix", "", bytes.NewBufferString("prefix1"))
storage.StoreObject("bucket", "newPrefix2", "", bytes.NewBufferString("prefix2")) storage.CreateObject("bucket", "newPrefix2", "", bytes.NewBufferString("prefix2"))
resources.Prefix = "new" resources.Prefix = "new"
resources.Maxkeys = 5 resources.Maxkeys = 5
objects, resources, err = storage.ListObjects("bucket", resources) objects, resources, err = storage.ListObjects("bucket", resources)
@ -131,8 +131,8 @@ func testPaging(c *check.C, create func() Storage) {
// check delimited results with delimiter and prefix // check delimited results with delimiter and prefix
{ {
storage.StoreObject("bucket", "this/is/delimited", "", bytes.NewBufferString("prefix1")) storage.CreateObject("bucket", "this/is/delimited", "", bytes.NewBufferString("prefix1"))
storage.StoreObject("bucket", "this/is/also/delimited", "", bytes.NewBufferString("prefix2")) storage.CreateObject("bucket", "this/is/also/delimited", "", bytes.NewBufferString("prefix2"))
var prefixes []string var prefixes []string
resources.CommonPrefixes = prefixes // allocate new everytime resources.CommonPrefixes = prefixes // allocate new everytime
resources.Delimiter = "/" resources.Delimiter = "/"
@ -184,12 +184,12 @@ func testPaging(c *check.C, create func() Storage) {
func testObjectOverwriteFails(c *check.C, create func() Storage) { func testObjectOverwriteFails(c *check.C, create func() Storage) {
storage := create() storage := create()
storage.CreateBucket("bucket") storage.CreateBucket("bucket")
err := storage.StoreObject("bucket", "object", "", bytes.NewBufferString("one")) err := storage.CreateObject("bucket", "object", "", bytes.NewBufferString("one"))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "object", "", bytes.NewBufferString("three")) err = storage.CreateObject("bucket", "object", "", bytes.NewBufferString("three"))
c.Assert(err, check.Not(check.IsNil)) c.Assert(err, check.Not(check.IsNil))
var bytesBuffer bytes.Buffer var bytesBuffer bytes.Buffer
length, err := storage.CopyObjectToWriter(&bytesBuffer, "bucket", "object") length, err := storage.GetObject(&bytesBuffer, "bucket", "object")
c.Assert(length, check.Equals, int64(len("one"))) c.Assert(length, check.Equals, int64(len("one")))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(string(bytesBuffer.Bytes()), check.Equals, "one") c.Assert(string(bytesBuffer.Bytes()), check.Equals, "one")
@ -197,7 +197,7 @@ func testObjectOverwriteFails(c *check.C, create func() Storage) {
func testNonExistantBucketOperations(c *check.C, create func() Storage) { func testNonExistantBucketOperations(c *check.C, create func() Storage) {
storage := create() storage := create()
err := storage.StoreObject("bucket", "object", "", bytes.NewBufferString("one")) err := storage.CreateObject("bucket", "object", "", bytes.NewBufferString("one"))
c.Assert(err, check.Not(check.IsNil)) c.Assert(err, check.Not(check.IsNil))
} }
@ -213,10 +213,10 @@ func testPutObjectInSubdir(c *check.C, create func() Storage) {
storage := create() storage := create()
err := storage.CreateBucket("bucket") err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world")) err = storage.CreateObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world"))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
var bytesBuffer bytes.Buffer var bytesBuffer bytes.Buffer
length, err := storage.CopyObjectToWriter(&bytesBuffer, "bucket", "dir1/dir2/object") length, err := storage.GetObject(&bytesBuffer, "bucket", "dir1/dir2/object")
c.Assert(len(bytesBuffer.Bytes()), check.Equals, len("hello world")) c.Assert(len(bytesBuffer.Bytes()), check.Equals, len("hello world"))
c.Assert(int64(len(bytesBuffer.Bytes())), check.Equals, length) c.Assert(int64(len(bytesBuffer.Bytes())), check.Equals, length)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
@ -286,7 +286,7 @@ func testNonExistantObjectInBucket(c *check.C, create func() Storage) {
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
var byteBuffer bytes.Buffer var byteBuffer bytes.Buffer
length, err := storage.CopyObjectToWriter(&byteBuffer, "bucket", "dir1") length, err := storage.GetObject(&byteBuffer, "bucket", "dir1")
c.Assert(length, check.Equals, int64(0)) c.Assert(length, check.Equals, int64(0))
c.Assert(err, check.Not(check.IsNil)) c.Assert(err, check.Not(check.IsNil))
c.Assert(len(byteBuffer.Bytes()), check.Equals, 0) c.Assert(len(byteBuffer.Bytes()), check.Equals, 0)
@ -307,11 +307,11 @@ func testGetDirectoryReturnsObjectNotFound(c *check.C, create func() Storage) {
err := storage.CreateBucket("bucket") err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world")) err = storage.CreateObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world"))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
var byteBuffer bytes.Buffer var byteBuffer bytes.Buffer
length, err := storage.CopyObjectToWriter(&byteBuffer, "bucket", "dir1") length, err := storage.GetObject(&byteBuffer, "bucket", "dir1")
c.Assert(length, check.Equals, int64(0)) c.Assert(length, check.Equals, int64(0))
switch err := err.(type) { switch err := err.(type) {
case ObjectNotFound: case ObjectNotFound:
@ -328,7 +328,7 @@ func testGetDirectoryReturnsObjectNotFound(c *check.C, create func() Storage) {
c.Assert(len(byteBuffer.Bytes()), check.Equals, 0) c.Assert(len(byteBuffer.Bytes()), check.Equals, 0)
var byteBuffer2 bytes.Buffer var byteBuffer2 bytes.Buffer
length, err = storage.CopyObjectToWriter(&byteBuffer, "bucket", "dir1/") length, err = storage.GetObject(&byteBuffer, "bucket", "dir1/")
c.Assert(length, check.Equals, int64(0)) c.Assert(length, check.Equals, int64(0))
switch err := err.(type) { switch err := err.(type) {
case ObjectNotFound: case ObjectNotFound:
@ -351,19 +351,19 @@ func testDefaultContentType(c *check.C, create func() Storage) {
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
// test empty // test empty
err = storage.StoreObject("bucket", "one", "", bytes.NewBufferString("one")) err = storage.CreateObject("bucket", "one", "", bytes.NewBufferString("one"))
metadata, err := storage.GetObjectMetadata("bucket", "one", "") metadata, err := storage.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
storage.StoreObject("bucket", "two", "application/text", bytes.NewBufferString("two")) storage.CreateObject("bucket", "two", "application/text", bytes.NewBufferString("two"))
metadata, err = storage.GetObjectMetadata("bucket", "two", "") metadata, err = storage.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
storage.StoreObject("bucket", "three", "\tapplication/json ", bytes.NewBufferString("three")) storage.CreateObject("bucket", "three", "\tapplication/json ", bytes.NewBufferString("three"))
metadata, err = storage.GetObjectMetadata("bucket", "three", "") metadata, err = storage.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")