Merge pull request #894 from harshavardhana/pr_out_add_more_cleanups_and_bug_fixes_from_minio_go_move_to_v0_2_0
Add more cleanups and bug-fixes from minio-go - move to v0.2.0
This commit is contained in:
Generated
+2
-2
@@ -28,8 +28,8 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio-go",
|
||||
"Comment": "v0.1.0-45-g02b1e1b",
|
||||
"Rev": "02b1e1bc4ba8f9498c29e8e81208dfba0bbb4346"
|
||||
"Comment": "v0.2.0",
|
||||
"Rev": "99af5f18ff7e0282b691ef3fab5e4f0f377f2b2a"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio/pkg/iodine",
|
||||
|
||||
+5
-5
@@ -103,7 +103,7 @@ func (a apiV1) listMultipartUploads(bucket, keymarker, uploadIDMarker, prefix, d
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return listMultipartUploadsResult{}, a.responseToError(resp.Body)
|
||||
return listMultipartUploadsResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
listMultipartUploadsResult := listMultipartUploadsResult{}
|
||||
@@ -142,7 +142,7 @@ func (a apiV1) initiateMultipartUpload(bucket, object string) (initiateMultipart
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return initiateMultipartUploadResult{}, a.responseToError(resp.Body)
|
||||
return initiateMultipartUploadResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
initiateMultipartUploadResult := initiateMultipartUploadResult{}
|
||||
@@ -198,7 +198,7 @@ func (a apiV1) completeMultipartUpload(bucket, object, uploadID string, c comple
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return completeMultipartUploadResult{}, a.responseToError(resp.Body)
|
||||
return completeMultipartUploadResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
completeMultipartUploadResult := completeMultipartUploadResult{}
|
||||
@@ -308,7 +308,7 @@ func (a apiV1) listObjectParts(bucket, object, uploadID string, partNumberMarker
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return listObjectPartsResult{}, a.responseToError(resp.Body)
|
||||
return listObjectPartsResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
listObjectPartsResult := listObjectPartsResult{}
|
||||
@@ -358,7 +358,7 @@ func (a apiV1) uploadPart(bucket, object, uploadID string, md5SumBytes []byte, p
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return completePart{}, a.responseToError(resp.Body)
|
||||
return completePart{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
return cPart, nil
|
||||
|
||||
+16
-16
@@ -130,7 +130,7 @@ func (a apiV1) putBucket(bucket, acl, location string) error {
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return a.responseToError(resp.Body)
|
||||
return a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -164,7 +164,7 @@ func (a apiV1) putBucketACL(bucket, acl string) error {
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return a.responseToError(resp.Body)
|
||||
return a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -197,7 +197,7 @@ func (a apiV1) getBucketACL(bucket string) (accessControlPolicy, error) {
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return accessControlPolicy{}, a.responseToError(resp.Body)
|
||||
return accessControlPolicy{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
policy := accessControlPolicy{}
|
||||
@@ -244,7 +244,7 @@ func (a apiV1) getBucketLocation(bucket string) (string, error) {
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", a.responseToError(resp.Body)
|
||||
return "", a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
var locationConstraint string
|
||||
@@ -313,7 +313,7 @@ func (a apiV1) listObjectsRequest(bucket, marker, prefix, delimiter string, maxk
|
||||
// ?prefix - Limits the response to keys that begin with the specified prefix.
|
||||
// ?max-keys - Sets the maximum number of keys returned in the response body.
|
||||
func (a apiV1) listObjects(bucket, marker, prefix, delimiter string, maxkeys int) (listBucketResult, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return listBucketResult{}, err
|
||||
}
|
||||
req, err := a.listObjectsRequest(bucket, marker, prefix, delimiter, maxkeys)
|
||||
@@ -327,7 +327,7 @@ func (a apiV1) listObjects(bucket, marker, prefix, delimiter string, maxkeys int
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return listBucketResult{}, a.responseToError(resp.Body)
|
||||
return listBucketResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
listBucketResult := listBucketResult{}
|
||||
@@ -351,7 +351,7 @@ func (a apiV1) headBucketRequest(bucket string) (*request, error) {
|
||||
|
||||
// headBucket useful to determine if a bucket exists and you have permission to access it.
|
||||
func (a apiV1) headBucket(bucket string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := a.headBucketRequest(bucket)
|
||||
@@ -412,7 +412,7 @@ func (a apiV1) deleteBucketRequest(bucket string) (*request, error) {
|
||||
// All objects (including all object versions and delete markers)
|
||||
// in the bucket must be deleted before successfully attempting this request
|
||||
func (a apiV1) deleteBucket(bucket string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := a.deleteBucketRequest(bucket)
|
||||
@@ -497,7 +497,7 @@ func (a apiV1) putObject(bucket, object, contentType string, md5SumBytes []byte,
|
||||
}
|
||||
if resp != nil {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return ObjectStat{}, a.responseToError(resp.Body)
|
||||
return ObjectStat{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
var metadata ObjectStat
|
||||
@@ -545,7 +545,7 @@ func (a apiV1) getObjectRequest(bucket, object string, offset, length int64) (*r
|
||||
//
|
||||
// For more information about the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
|
||||
func (a apiV1) getObject(bucket, object string, offset, length int64) (io.ReadCloser, ObjectStat, error) {
|
||||
if err := invalidArgumentToError(object); err != nil {
|
||||
if err := invalidArgumentError(object); err != nil {
|
||||
return nil, ObjectStat{}, err
|
||||
}
|
||||
req, err := a.getObjectRequest(bucket, object, offset, length)
|
||||
@@ -561,7 +561,7 @@ func (a apiV1) getObject(bucket, object string, offset, length int64) (io.ReadCl
|
||||
case http.StatusOK:
|
||||
case http.StatusPartialContent:
|
||||
default:
|
||||
return nil, ObjectStat{}, a.responseToError(resp.Body)
|
||||
return nil, ObjectStat{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
md5sum := strings.Trim(resp.Header.Get("ETag"), "\"") // trim off the odd double quotes
|
||||
@@ -611,10 +611,10 @@ func (a apiV1) deleteObjectRequest(bucket, object string) (*request, error) {
|
||||
|
||||
// deleteObject deletes a given object from a bucket
|
||||
func (a apiV1) deleteObject(bucket, object string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := invalidArgumentToError(object); err != nil {
|
||||
if err := invalidArgumentError(object); err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := a.deleteObjectRequest(bucket, object)
|
||||
@@ -674,10 +674,10 @@ func (a apiV1) headObjectRequest(bucket, object string) (*request, error) {
|
||||
|
||||
// headObject retrieves metadata from an object without returning the object itself
|
||||
func (a apiV1) headObject(bucket, object string) (ObjectStat, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return ObjectStat{}, err
|
||||
}
|
||||
if err := invalidArgumentToError(object); err != nil {
|
||||
if err := invalidArgumentError(object); err != nil {
|
||||
return ObjectStat{}, err
|
||||
}
|
||||
req, err := a.headObjectRequest(bucket, object)
|
||||
@@ -790,7 +790,7 @@ func (a apiV1) listBuckets() (listAllMyBucketsResult, error) {
|
||||
}
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return listAllMyBucketsResult{}, a.responseToError(resp.Body)
|
||||
return listAllMyBucketsResult{}, a.ToErrorResponseBody(resp.Body)
|
||||
}
|
||||
}
|
||||
listAllMyBucketsResult := listAllMyBucketsResult{}
|
||||
|
||||
+22
-22
@@ -172,7 +172,7 @@ type Config struct {
|
||||
// Global constants
|
||||
const (
|
||||
LibraryName = "minio-go"
|
||||
LibraryVersion = "0.1.0"
|
||||
LibraryVersion = "0.2.0"
|
||||
)
|
||||
|
||||
// SetUserAgent - append to a default user agent
|
||||
@@ -212,10 +212,10 @@ func New(config Config) (API, error) {
|
||||
|
||||
// Downloads full object with no ranges, if you need ranges use GetPartialObject
|
||||
func (a apiV2) GetObject(bucket, object string) (io.ReadCloser, ObjectStat, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return nil, ObjectStat{}, err
|
||||
}
|
||||
if err := invalidObjectToError(object); err != nil {
|
||||
if err := invalidObjectError(object); err != nil {
|
||||
return nil, ObjectStat{}, err
|
||||
}
|
||||
// get object
|
||||
@@ -228,10 +228,10 @@ func (a apiV2) GetObject(bucket, object string) (io.ReadCloser, ObjectStat, erro
|
||||
// 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 apiV2) GetPartialObject(bucket, object string, offset, length int64) (io.ReadCloser, ObjectStat, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return nil, ObjectStat{}, err
|
||||
}
|
||||
if err := invalidObjectToError(object); err != nil {
|
||||
if err := invalidObjectError(object); err != nil {
|
||||
return nil, ObjectStat{}, err
|
||||
}
|
||||
// get partial object
|
||||
@@ -468,10 +468,10 @@ func (a apiV2) listMultipartUploadsRecursiveInRoutine(bucket, object string, ch
|
||||
//
|
||||
// This version of PutObject automatically does multipart for more than 5MB worth of data
|
||||
func (a apiV2) PutObject(bucket, object, contentType string, size int64, data io.Reader) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := invalidArgumentToError(object); err != nil {
|
||||
if err := invalidArgumentError(object); err != nil {
|
||||
return err
|
||||
}
|
||||
switch {
|
||||
@@ -516,10 +516,10 @@ func (a apiV2) PutObject(bucket, object, contentType string, size int64, data io
|
||||
|
||||
// StatObject verify if object exists and you have permission to access it
|
||||
func (a apiV2) StatObject(bucket, object string) (ObjectStat, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return ObjectStat{}, err
|
||||
}
|
||||
if err := invalidObjectToError(object); err != nil {
|
||||
if err := invalidObjectError(object); err != nil {
|
||||
return ObjectStat{}, err
|
||||
}
|
||||
return a.headObject(bucket, object)
|
||||
@@ -527,10 +527,10 @@ func (a apiV2) StatObject(bucket, object string) (ObjectStat, error) {
|
||||
|
||||
// RemoveObject remove the object from a bucket
|
||||
func (a apiV2) RemoveObject(bucket, object string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := invalidObjectToError(object); err != nil {
|
||||
if err := invalidObjectError(object); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.deleteObject(bucket, object)
|
||||
@@ -556,11 +556,11 @@ func (a apiV2) RemoveObject(bucket, object string) error {
|
||||
// [ us-west-1 | us-west-2 | eu-west-1 | eu-central-1 | ap-southeast-1 | ap-northeast-1 | ap-southeast-2 | sa-east-1 ]
|
||||
// Default - US standard
|
||||
func (a apiV2) MakeBucket(bucket string, acl BucketACL) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if !acl.isValidBucketACL() {
|
||||
return invalidArgumentToError("")
|
||||
return invalidArgumentError("")
|
||||
}
|
||||
location, _ := getRegion(a.config.Endpoint)
|
||||
if location == "milkyway" {
|
||||
@@ -582,11 +582,11 @@ func (a apiV2) MakeBucket(bucket string, acl BucketACL) error {
|
||||
// authenticated-read - owner gets full access, authenticated users get read access
|
||||
//
|
||||
func (a apiV2) SetBucketACL(bucket string, acl BucketACL) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if !acl.isValidBucketACL() {
|
||||
return invalidArgumentToError("")
|
||||
return invalidArgumentError("")
|
||||
}
|
||||
return a.putBucketACL(bucket, string(acl))
|
||||
}
|
||||
@@ -601,7 +601,7 @@ func (a apiV2) SetBucketACL(bucket string, acl BucketACL) error {
|
||||
// authenticated-read - owner gets full access, authenticated users get read access
|
||||
//
|
||||
func (a apiV2) GetBucketACL(bucket string) (BucketACL, error) {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return "", err
|
||||
}
|
||||
policy, err := a.getBucketACL(bucket)
|
||||
@@ -640,7 +640,7 @@ func (a apiV2) GetBucketACL(bucket string) (BucketACL, error) {
|
||||
|
||||
// BucketExists verify if bucket exists and you have permission to access it
|
||||
func (a apiV2) BucketExists(bucket string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.headBucket(bucket)
|
||||
@@ -651,7 +651,7 @@ func (a apiV2) BucketExists(bucket string) error {
|
||||
// All objects (including all object versions and delete markers)
|
||||
// in the bucket must be deleted before successfully attempting this request
|
||||
func (a apiV2) RemoveBucket(bucket string) error {
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.deleteBucket(bucket)
|
||||
@@ -661,7 +661,7 @@ func (a apiV2) RemoveBucket(bucket string) error {
|
||||
// This function feeds data into channel
|
||||
func (a apiV2) listObjectsInRoutine(bucket, prefix string, recursive bool, ch chan ObjectStatCh) {
|
||||
defer close(ch)
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
ch <- ObjectStatCh{
|
||||
Stat: ObjectStat{},
|
||||
Err: err,
|
||||
@@ -787,11 +787,11 @@ func (a apiV2) ListBuckets() <-chan BucketStatCh {
|
||||
|
||||
func (a apiV2) dropIncompleteUploadsInRoutine(bucket, object string, errorCh chan error) {
|
||||
defer close(errorCh)
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
if err := invalidObjectToError(object); err != nil {
|
||||
if err := invalidObjectError(object); err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
@@ -843,7 +843,7 @@ func (a apiV2) DropIncompleteUploads(bucket, object string) <-chan error {
|
||||
|
||||
func (a apiV2) dropAllIncompleteUploadsInRoutine(bucket string, errorCh chan error) {
|
||||
defer close(errorCh)
|
||||
if err := invalidBucketToError(bucket); err != nil {
|
||||
if err := invalidBucketError(bucket); err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ func TestErrorResponse(t *testing.T) {
|
||||
a := apiV1{&Config{}}
|
||||
errorResponse := []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>AccessDenied</Code><Message>Access Denied</Message><Resource>/mybucket/myphoto.jpg</Resource><RequestId>F19772218238A85A</RequestId><HostId>GuWkjyviSiGHizehqpmsD1ndz5NClSP19DOT+s2mv7gXGQ8/X1lhbDGiIJEXpGFD</HostId></Error>")
|
||||
errorReader := bytes.NewReader(errorResponse)
|
||||
err := a.responseToError(errorReader)
|
||||
err := a.ToErrorResponseBody(errorReader)
|
||||
if err == nil {
|
||||
t.Fatal("Error")
|
||||
}
|
||||
|
||||
+11
-10
@@ -87,19 +87,18 @@ func (e ErrorResponse) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
/// Internal function not exposed
|
||||
|
||||
// responseToError returns a new encoded ErrorResponse structure
|
||||
func (a apiV1) responseToError(errBody io.Reader) error {
|
||||
var respError ErrorResponse
|
||||
err := acceptTypeDecoder(errBody, a.config.AcceptType, &respError)
|
||||
// ToErrorResponseBody returns a new encoded ErrorResponse structure
|
||||
func (a apiV1) ToErrorResponseBody(errBody io.Reader) error {
|
||||
var errorResponse ErrorResponse
|
||||
err := acceptTypeDecoder(errBody, a.config.AcceptType, &errorResponse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return respError
|
||||
return errorResponse
|
||||
}
|
||||
|
||||
func invalidBucketToError(bucket string) error {
|
||||
// invalidBucketToError - invalid bucket to errorResponse
|
||||
func invalidBucketError(bucket string) error {
|
||||
// verify bucket name in accordance with
|
||||
// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html
|
||||
isValidBucket := func(bucket string) bool {
|
||||
@@ -129,7 +128,8 @@ func invalidBucketToError(bucket string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func invalidObjectToError(object string) error {
|
||||
// invalidObjectError invalid object name to errorResponse
|
||||
func invalidObjectError(object string) error {
|
||||
if strings.TrimSpace(object) == "" || object == "" {
|
||||
// no resource since object name is empty
|
||||
errorResponse := ErrorResponse{
|
||||
@@ -142,7 +142,8 @@ func invalidObjectToError(object string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func invalidArgumentToError(arg string) error {
|
||||
// invalidArgumentError invalid argument to errorResponse
|
||||
func invalidArgumentError(arg string) error {
|
||||
errorResponse := ErrorResponse{
|
||||
Code: "InvalidArgument",
|
||||
Message: "Invalid Argument",
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
Generated
Vendored
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
Generated
Vendored
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -28,9 +28,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
Generated
Vendored
+1
-3
@@ -28,9 +28,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -27,9 +27,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
|
||||
func main() {
|
||||
config := minio.Config{
|
||||
AccessKeyID: "YOUR-ACCESS-KEY-HERE",
|
||||
SecretAccessKey: "YOUR-PASSWORD-HERE",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
Endpoint: "https://play.minio.io:9000",
|
||||
}
|
||||
s3Client, err := minio.New(config)
|
||||
if err != nil {
|
||||
|
||||
Generated
Vendored
+71
-58
@@ -16,13 +16,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package minio
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/minio/minio-go"
|
||||
)
|
||||
|
||||
// SET THESE!
|
||||
@@ -30,19 +32,19 @@ var bucket = ""
|
||||
var accessKeyID = ""
|
||||
var secretAccessKey = ""
|
||||
|
||||
var config = Config{
|
||||
var config = minio.Config{
|
||||
AccessKeyID: accessKeyID,
|
||||
SecretAccessKey: secretAccessKey,
|
||||
Endpoint: "https://s3-us-west-2.amazonaws.com",
|
||||
}
|
||||
var client, _ = New(config)
|
||||
var client, _ = minio.New(config)
|
||||
|
||||
var standardConfig = Config{
|
||||
var standardConfig = minio.Config{
|
||||
AccessKeyID: accessKeyID,
|
||||
SecretAccessKey: secretAccessKey,
|
||||
Endpoint: "https://s3.amazonaws.com",
|
||||
}
|
||||
var standardClient, _ = New(standardConfig)
|
||||
var standardClient, _ = minio.New(standardConfig)
|
||||
|
||||
func TestMakeBucket(t *testing.T) {
|
||||
err := client.MakeBucket(bucket, "private")
|
||||
@@ -124,7 +126,7 @@ func TestBucketAcls(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("get prw failed")
|
||||
}
|
||||
if !acl.isPublic() {
|
||||
if acl.String() != "public-read-write" {
|
||||
t.Error("prw wasn't prw")
|
||||
}
|
||||
|
||||
@@ -133,11 +135,10 @@ func TestBucketAcls(t *testing.T) {
|
||||
t.Error("set pr failed")
|
||||
}
|
||||
acl, err = client.GetBucketACL(bucket)
|
||||
log.Println("pr: ", acl)
|
||||
if err != nil {
|
||||
t.Error("get pr failed")
|
||||
}
|
||||
if !acl.isReadOnly() {
|
||||
if acl.String() != "public-read" {
|
||||
t.Error("pr wasn't pr")
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ func TestBucketAcls(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("get ar failed")
|
||||
}
|
||||
if !acl.isAuthenticated() {
|
||||
if acl.String() != "authenticated-read" {
|
||||
t.Error("ar wasn't ar")
|
||||
}
|
||||
|
||||
@@ -161,8 +162,7 @@ func TestBucketAcls(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("get p failed")
|
||||
}
|
||||
log.Println("p:", acl)
|
||||
if !acl.isPrivate() {
|
||||
if acl.String() != "private" {
|
||||
t.Error("p wasn't p")
|
||||
}
|
||||
}
|
||||
@@ -385,13 +385,13 @@ func TestPutLargeTextFile(t *testing.T) {
|
||||
key := "large/text_file"
|
||||
fileName := "/tmp/11m_text"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -407,13 +407,13 @@ func TestPutLargeBinaryFile(t *testing.T) {
|
||||
key := "large/binary_file"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -422,20 +422,22 @@ func TestPutLargeBinaryFile(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeSizeTooSmall(t *testing.T) {
|
||||
key := "large/toosmall"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = client.PutObject(bucket, key, "", fileStat.Size()-1, file); err == nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -446,13 +448,13 @@ func TestPutLargeSizeTooLarge(t *testing.T) {
|
||||
key := "large/toolarge"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = client.PutObject(bucket, key, "", fileStat.Size()+1, file); err == nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -463,13 +465,13 @@ func TestPutLargeBinaryFileContentType(t *testing.T) {
|
||||
key := "large/text_plain"
|
||||
fileName := "/tmp/11m_text"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "plain/text", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -478,20 +480,22 @@ func TestPutLargeBinaryFileContentType(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithQuestionMark(t *testing.T) {
|
||||
key := "large/obj?ect"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -500,20 +504,22 @@ func TestPutLargeBinaryFileWithQuestionMark(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithHashMark(t *testing.T) {
|
||||
key := "large/obj#ect"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -522,20 +528,22 @@ func TestPutLargeBinaryFileWithHashMark(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithUnicode1(t *testing.T) {
|
||||
key := "large/世界"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -544,20 +552,22 @@ func TestPutLargeBinaryFileWithUnicode1(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithUnicode2(t *testing.T) {
|
||||
key := "large/世界世"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -566,7 +576,9 @@ func TestPutLargeBinaryFileWithUnicode2(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithUnicode3(t *testing.T) {
|
||||
@@ -577,36 +589,37 @@ func TestPutLargeBinaryFileWithUnicode3(t *testing.T) {
|
||||
key := "large/世界世界"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size(), file); err != nil {
|
||||
log.Println(fileStat.Size())
|
||||
t.Error(err)
|
||||
}
|
||||
stat, err := client.StatObject(bucket, key)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Println(stat)
|
||||
if stat.Key != key {
|
||||
t.Error("invalid stat")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPutLargeBinaryFileWithUnicode4(t *testing.T) {
|
||||
key := "large/4世界世界世"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size()-1, file); err == nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -617,13 +630,13 @@ func TestPutLargeBinaryFileWithUnicode5(t *testing.T) {
|
||||
key := "large/5世界世界世界"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size()-1, file); err == nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
@@ -634,13 +647,13 @@ func TestPutLargeBinaryFileWithUnicode6(t *testing.T) {
|
||||
key := "large/6世界世界世界世"
|
||||
fileName := "/tmp/11m_binary"
|
||||
file, err := os.Open(fileName)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
fileStat, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.PutObject(bucket, key, "", fileStat.Size()-1, file); err == nil {
|
||||
t.Error("Should fail when length is too large")
|
||||
Reference in New Issue
Block a user