Merge pull request #402 from harshavardhana/pr_out_bring_multipartupload_interface_stubs
This commit is contained in:
@@ -35,6 +35,34 @@ type Client interface {
|
||||
GetPartial(bucket, key string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error)
|
||||
Put(bucket, object, md5 string, size int64) (io.WriteCloser, error)
|
||||
GetObjectMetadata(bucket, object string) (item *Item, err error)
|
||||
|
||||
// Multipart operations
|
||||
MultipartUpload
|
||||
}
|
||||
|
||||
// MultipartUpload - multi part upload interface
|
||||
type MultipartUpload interface {
|
||||
InitiateMultiPartUpload(bucket, object string) (objectID string, err error)
|
||||
UploadPart(bucket, object, uploadID string, partNumber int) (md5hex string, err error)
|
||||
CompleteMultiPartUpload(bucket, object, uploadID string) (location, md5hex string, err error)
|
||||
AbortMultiPartUpload(bucket, object, uploadID string) error
|
||||
ListParts(bucket, object, uploadID string) (items *PartItems, err error)
|
||||
}
|
||||
|
||||
// Part - part xml response
|
||||
type Part struct {
|
||||
PartNumber int
|
||||
LastModified time.Time
|
||||
ETag string
|
||||
Size int64
|
||||
}
|
||||
|
||||
// PartItems - part xml items response
|
||||
type PartItems struct {
|
||||
Key string
|
||||
UploadID string
|
||||
IsTruncated bool
|
||||
Part []*Part
|
||||
}
|
||||
|
||||
// Bucket - carries s3 bucket reply header
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Mini Copy, (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this fs except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// Multipart object upload handlers
|
||||
|
||||
// InitiateMultiPartUpload -
|
||||
func (c *fsClient) InitiateMultiPartUpload(bucket, object string) (objectID string, err error) {
|
||||
return "", iodine.New(client.APINotImplemented{API: "InitiateMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// UploadPart -
|
||||
func (c *fsClient) UploadPart(bucket, object, uploadID string, partNumber int) (md5hex string, err error) {
|
||||
return "", iodine.New(client.APINotImplemented{API: "UploadPart"}, nil)
|
||||
}
|
||||
|
||||
// CompleteMultiPartUpload -
|
||||
func (c *fsClient) CompleteMultiPartUpload(bucket, object, uploadID string) (location, md5hex string, err error) {
|
||||
return "", "", iodine.New(client.APINotImplemented{API: "CompleteMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// AbortMultiPartUpload -
|
||||
func (c *fsClient) AbortMultiPartUpload(bucket, object, uploadID string) error {
|
||||
return iodine.New(client.APINotImplemented{API: "AbortMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// ListParts -
|
||||
func (c *fsClient) ListParts(bucket, object, uploadID string) (items *client.PartItems, err error) {
|
||||
return nil, iodine.New(client.APINotImplemented{API: "ListParts"}, nil)
|
||||
}
|
||||
@@ -54,11 +54,11 @@ import (
|
||||
/// Object API operations
|
||||
|
||||
// GetObjectMetadata - returns nil, os.ErrNotExist if not on object storage
|
||||
func (c *s3Client) GetObjectMetadata(bucket, key string) (item *client.Item, reterr error) {
|
||||
if bucket == "" || key == "" {
|
||||
func (c *s3Client) GetObjectMetadata(bucket, object string) (item *client.Item, reterr error) {
|
||||
if bucket == "" || object == "" {
|
||||
return nil, iodine.New(client.InvalidArgument{}, nil)
|
||||
}
|
||||
req, err := newReq(c.keyURL(bucket, key), c.UserAgent, nil)
|
||||
req, err := newReq(c.keyURL(bucket, object), c.UserAgent, nil)
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (c *s3Client) GetObjectMetadata(bucket, key string) (item *client.Item, ret
|
||||
defer res.Body.Close()
|
||||
switch res.StatusCode {
|
||||
case http.StatusNotFound:
|
||||
return nil, iodine.New(client.ObjectNotFound{Bucket: bucket, Object: key}, nil)
|
||||
return nil, iodine.New(client.ObjectNotFound{Bucket: bucket, Object: object}, nil)
|
||||
case http.StatusOK:
|
||||
contentLength, err := strconv.ParseInt(res.Header.Get("Content-Length"), 10, 64)
|
||||
if err != nil {
|
||||
@@ -84,7 +84,7 @@ func (c *s3Client) GetObjectMetadata(bucket, key string) (item *client.Item, ret
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
item = new(client.Item)
|
||||
item.Key = key
|
||||
item.Key = object
|
||||
item.LastModified = date
|
||||
item.Size = contentLength
|
||||
item.ETag = strings.Trim(res.Header.Get("ETag"), "\"")
|
||||
@@ -95,8 +95,11 @@ func (c *s3Client) GetObjectMetadata(bucket, key string) (item *client.Item, ret
|
||||
}
|
||||
|
||||
// Get - download a requested object from a given bucket
|
||||
func (c *s3Client) Get(bucket, key string) (body io.ReadCloser, size int64, md5 string, err error) {
|
||||
req, err := newReq(c.keyURL(bucket, key), c.UserAgent, nil)
|
||||
func (c *s3Client) Get(bucket, object string) (body io.ReadCloser, size int64, md5 string, err error) {
|
||||
if bucket == "" || object == "" {
|
||||
return nil, 0, "", iodine.New(client.InvalidArgument{}, nil)
|
||||
}
|
||||
req, err := newReq(c.keyURL(bucket, object), c.UserAgent, nil)
|
||||
if err != nil {
|
||||
return nil, 0, "", iodine.New(err, nil)
|
||||
}
|
||||
@@ -113,13 +116,16 @@ func (c *s3Client) Get(bucket, key string) (body io.ReadCloser, size int64, md5
|
||||
return res.Body, res.ContentLength, md5sum, nil
|
||||
}
|
||||
|
||||
// GetPartial fetches part of the s3 key object in bucket.
|
||||
// GetPartial fetches part of the s3 object in bucket.
|
||||
// If length is negative, the rest of the object is returned.
|
||||
func (c *s3Client) GetPartial(bucket, key string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error) {
|
||||
func (c *s3Client) GetPartial(bucket, object string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error) {
|
||||
if bucket == "" || object == "" {
|
||||
return nil, 0, "", iodine.New(client.InvalidArgument{}, nil)
|
||||
}
|
||||
if offset < 0 {
|
||||
return nil, 0, "", iodine.New(client.InvalidRange{Offset: offset}, nil)
|
||||
}
|
||||
req, err := newReq(c.keyURL(bucket, key), c.UserAgent, nil)
|
||||
req, err := newReq(c.keyURL(bucket, object), c.UserAgent, nil)
|
||||
if err != nil {
|
||||
return nil, 0, "", iodine.New(err, nil)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Mini Copy, (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this fs except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package s3
|
||||
|
||||
import (
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// Multipart object upload handlers
|
||||
|
||||
// InitiateMultiPartUpload
|
||||
func (c *s3Client) InitiateMultiPartUpload(bucket, object string) (objectID string, err error) {
|
||||
return "", iodine.New(client.APINotImplemented{API: "InitiateMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// UploadPart
|
||||
func (c *s3Client) UploadPart(bucket, object, uploadID string, partNumber int) (md5hex string, err error) {
|
||||
return "", iodine.New(client.APINotImplemented{API: "UploadPart"}, nil)
|
||||
}
|
||||
|
||||
// CompleteMultiPartUpload
|
||||
func (c *s3Client) CompleteMultiPartUpload(bucket, object, uploadID string) (location, md5hex string, err error) {
|
||||
return "", "", iodine.New(client.APINotImplemented{API: "CompleteMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// AbortMultiPartUpload
|
||||
func (c *s3Client) AbortMultiPartUpload(bucket, object, uploadID string) error {
|
||||
return iodine.New(client.APINotImplemented{API: "AbortMultiPartUpload"}, nil)
|
||||
}
|
||||
|
||||
// ListParts
|
||||
func (c *s3Client) ListParts(bucket, object, uploadID string) (items *client.PartItems, err error) {
|
||||
return nil, iodine.New(client.APINotImplemented{API: "ListParts"}, nil)
|
||||
|
||||
}
|
||||
@@ -30,11 +30,11 @@ import (
|
||||
/// Object Operations PUT - keeping this in a separate file for readability
|
||||
|
||||
// Put - upload new object to bucket
|
||||
func (c *s3Client) Put(bucket, key, md5HexString string, size int64) (io.WriteCloser, error) {
|
||||
func (c *s3Client) Put(bucket, object, md5HexString string, size int64) (io.WriteCloser, error) {
|
||||
r, w := io.Pipe()
|
||||
blockingWriter := NewBlockingWriteCloser(w)
|
||||
go func() {
|
||||
req, err := newReq(c.keyURL(bucket, key), c.UserAgent, r)
|
||||
req, err := newReq(c.keyURL(bucket, object), c.UserAgent, r)
|
||||
if err != nil {
|
||||
err := iodine.New(err, nil)
|
||||
r.CloseWithError(err)
|
||||
|
||||
Reference in New Issue
Block a user