mc uploads with default application/octet-stream
This commit is contained in:
Generated
+1
-1
@@ -28,7 +28,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio-go",
|
||||
"Rev": "7ece99186572e9cea437333e33b862ecfcfc95c8"
|
||||
"Rev": "77eadd00bfa2e6b7ae39f74a4f8b698df5ec9672"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio/pkg/iodine",
|
||||
|
||||
+3
-3
@@ -38,9 +38,9 @@ func main() {
|
||||
## Documentation
|
||||
|
||||
* [PutObject(string, string, int64, io.Reader) error](examples/s3/putobject.go)
|
||||
* [GetObject(string, string](examples/s3/getobject.go)
|
||||
* [ListObjects(string, string, bool) <-chan](examples/s3/listobjects.go)
|
||||
* [ListBuckets() <-chan](examples/s3/listbuckets.go)
|
||||
* [GetObject(string, string) (io.Reader, struct{}, error)](examples/s3/getobject.go)
|
||||
* [ListObjects(string, string, bool) <-chan struct{}](examples/s3/listobjects.go)
|
||||
* [ListBuckets() <-chan struct{}](examples/s3/listbuckets.go)
|
||||
|
||||
### API Reference
|
||||
|
||||
|
||||
+16
-7
@@ -54,8 +54,9 @@ type BucketAPI interface {
|
||||
|
||||
// ObjectAPI - object specific Read/Write/Stat interface
|
||||
type ObjectAPI interface {
|
||||
GetObject(bucket, object string) (io.ReadCloser, ObjectStat, error)
|
||||
GetPartialObject(bucket, object string, offset, length int64) (io.ReadCloser, ObjectStat, error)
|
||||
PutObject(bucket, object string, size int64, data io.Reader) error
|
||||
PutObject(bucket, object, contentType string, size int64, data io.Reader) error
|
||||
StatObject(bucket, object string) (ObjectStat, error)
|
||||
RemoveObject(bucket, object string) error
|
||||
|
||||
@@ -181,13 +182,21 @@ func New(config Config) (API, error) {
|
||||
|
||||
/// Object operations
|
||||
|
||||
// GetPartialObject retrieve object
|
||||
// GetObject retrieve object
|
||||
|
||||
// Downloads full object with no ranges, if you need ranges use GetPartialObject
|
||||
func (a api) GetObject(bucket, object string) (io.ReadCloser, ObjectStat, error) {
|
||||
// get object
|
||||
return a.getPartialObject(bucket, object, 0, 0)
|
||||
}
|
||||
|
||||
// GetPartialObject retrieve partial object
|
||||
//
|
||||
// Takes range arguments to download the specified range bytes of an object.
|
||||
// Setting offset and length = 0 will download the full object.
|
||||
// For more information about the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
|
||||
func (a api) GetPartialObject(bucket, object string, offset, length int64) (io.ReadCloser, ObjectStat, error) {
|
||||
// get the the object
|
||||
// get partial object
|
||||
return a.getPartialObject(bucket, object, offset, length)
|
||||
}
|
||||
|
||||
@@ -235,7 +244,7 @@ func getPartSize(objectSize int64) int64 {
|
||||
}
|
||||
}
|
||||
|
||||
func (a api) newObjectUpload(bucket, object string, size int64, data io.Reader) error {
|
||||
func (a api) newObjectUpload(bucket, object, contentType string, size int64, data io.Reader) error {
|
||||
initiateMultipartUploadResult, err := a.initiateMultipartUpload(bucket, object)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -405,7 +414,7 @@ func (a api) listMultipartUploadsRecursiveInRoutine(bucket, prefix string, ch ch
|
||||
// You must have WRITE permissions on a bucket to create an object
|
||||
//
|
||||
// This version of PutObject automatically does multipart for more than 5MB worth of data
|
||||
func (a api) PutObject(bucket, object string, size int64, data io.Reader) error {
|
||||
func (a api) PutObject(bucket, object, contentType string, size int64, data io.Reader) error {
|
||||
if err := invalidArgumentToError(object); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -416,7 +425,7 @@ func (a api) PutObject(bucket, object string, size int64, data io.Reader) error
|
||||
if part.Err != nil {
|
||||
return part.Err
|
||||
}
|
||||
_, err := a.putObject(bucket, object, part.Md5Sum, part.Len, part.ReadSeeker)
|
||||
_, err := a.putObject(bucket, object, contentType, part.Md5Sum, part.Len, part.ReadSeeker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -436,7 +445,7 @@ func (a api) PutObject(bucket, object string, size int64, data io.Reader) error
|
||||
}
|
||||
}
|
||||
if !inProgress {
|
||||
return a.newObjectUpload(bucket, object, size, data)
|
||||
return a.newObjectUpload(bucket, object, contentType, size, data)
|
||||
}
|
||||
return a.continueObjectUpload(bucket, object, inProgressUploadID, size, data)
|
||||
}
|
||||
|
||||
+2
-2
@@ -151,7 +151,7 @@ func TestObjectOperations(t *testing.T) {
|
||||
t.Fatalf("Error")
|
||||
}
|
||||
data := []byte("Hello, World")
|
||||
err = a.PutObject("bucket", "object", int64(len(data)), bytes.NewReader(data))
|
||||
err = a.PutObject("bucket", "object", "", int64(len(data)), bytes.NewReader(data))
|
||||
if err != nil {
|
||||
t.Fatalf("Error")
|
||||
}
|
||||
@@ -166,7 +166,7 @@ func TestObjectOperations(t *testing.T) {
|
||||
t.Fatalf("Error")
|
||||
}
|
||||
|
||||
reader, metadata, err := a.GetPartialObject("bucket", "object", 0, 0)
|
||||
reader, metadata, err := a.GetObject("bucket", "object")
|
||||
if err != nil {
|
||||
t.Fatalf("Error")
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
reader, stat, err := s3Client.GetPartialObject("mybucket", "myobject", 0, 0)
|
||||
reader, stat, err := s3Client.GetObject("mybucket", "myobject")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
+7
-3
@@ -428,7 +428,10 @@ func (a lowLevelAPI) deleteBucket(bucket string) error {
|
||||
/// Object Read/Write/Stat Operations
|
||||
|
||||
// putObjectRequest wrapper creates a new PutObject request
|
||||
func (a lowLevelAPI) putObjectRequest(bucket, object string, md5SumBytes []byte, size int64, body io.ReadSeeker) (*request, error) {
|
||||
func (a lowLevelAPI) putObjectRequest(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.ReadSeeker) (*request, error) {
|
||||
if strings.TrimSpace(contentType) == "" {
|
||||
contentType = "application/octet-stream"
|
||||
}
|
||||
encodedObject, err := urlEncodeName(object)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -444,6 +447,7 @@ func (a lowLevelAPI) putObjectRequest(bucket, object string, md5SumBytes []byte,
|
||||
}
|
||||
// set Content-MD5 as base64 encoded md5
|
||||
r.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5SumBytes))
|
||||
r.Set("Content-Type", contentType)
|
||||
r.req.ContentLength = size
|
||||
return r, nil
|
||||
}
|
||||
@@ -451,8 +455,8 @@ func (a lowLevelAPI) putObjectRequest(bucket, object string, md5SumBytes []byte,
|
||||
// putObject - add an object to a bucket
|
||||
//
|
||||
// You must have WRITE permissions on a bucket to add an object to it.
|
||||
func (a lowLevelAPI) putObject(bucket, object string, md5SumBytes []byte, size int64, body io.ReadSeeker) (ObjectStat, error) {
|
||||
req, err := a.putObjectRequest(bucket, object, md5SumBytes, size, body)
|
||||
func (a lowLevelAPI) putObject(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.ReadSeeker) (ObjectStat, error) {
|
||||
req, err := a.putObjectRequest(bucket, object, contentType, md5SumBytes, size, body)
|
||||
if err != nil {
|
||||
return ObjectStat{}, err
|
||||
}
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ func (c *s3Client) PutObject(size int64, data io.Reader) error {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
// TODO - bump individual part size from default, if needed
|
||||
// s3.DefaultPartSize = 1024 * 1024 * 100
|
||||
err := c.api.PutObject(bucket, object, size, data)
|
||||
err := c.api.PutObject(bucket, object, "application/octet-stream", size, data)
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user