diff --git a/common-methods.go b/common-methods.go index ba20a6d6..70d5b9f1 100644 --- a/common-methods.go +++ b/common-methods.go @@ -57,7 +57,7 @@ func getSource(sourceURL string) (reader io.ReadCloser, length int64, err *probe return sourceClnt.Get(0, 0) } -// putTarget writes to URL from reader. If length=0, read until EOF. +// putTarget writes to URL from reader. If length=-1, read until EOF. func putTarget(targetURL string, length int64, reader io.Reader) *probe.Error { targetClnt, err := url2Client(targetURL) if err != nil { @@ -70,7 +70,7 @@ func putTarget(targetURL string, length int64, reader io.Reader) *probe.Error { return nil } -// putTargets writes to URL from reader. If length=0, read until EOF. +// putTargets writes to URL from reader. If length=-1, read until EOF. func putTargets(targetURLs []string, length int64, reader io.Reader) *probe.Error { var tgtReaders []*io.PipeReader var tgtWriters []*io.PipeWriter @@ -98,7 +98,7 @@ func putTargets(targetURLs []string, length int64, reader io.Reader) *probe.Erro multiTgtWriter := io.MultiWriter(writers...) var e error switch length { - case 0: + case -1: _, e = io.Copy(multiTgtWriter, reader) default: _, e = io.CopyN(multiTgtWriter, reader, length) diff --git a/pipe-main.go b/pipe-main.go index b42c06a7..60d1ac7e 100644 --- a/pipe-main.go +++ b/pipe-main.go @@ -57,8 +57,9 @@ func checkPipeSyntax(ctx *cli.Context) { // pipe writes contents of stdin a collection of URLs. func pipe(targetURLs []string) *probe.Error { // Stream from stdin to multiple objects until EOF. - // Ignore size, since os.Stat() would not return proper size all the time for local filesystem for example /proc files. - err := putTargets(targetURLs, 0, os.Stdin) + // Ignore size, since os.Stat() would not return proper size all the time + // for local filesystem for example /proc files. + err := putTargets(targetURLs, -1, os.Stdin) // TODO: See if this check is necessary. switch e := err.ToGoError().(type) { case *os.PathError: diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go index 83deabf7..bd88b1c3 100644 --- a/vendor/github.com/minio/minio-go/api.go +++ b/vendor/github.com/minio/minio-go/api.go @@ -640,7 +640,18 @@ func (a API) continueObjectUpload(bucket, object, uploadID string, size int64, d // // 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. +// - For size lesser than 5MB PutObject automatically does single Put operation. +// - For size equal to 0Bytes PutObject automatically does single Put operation. +// - For size larger than 5MB PutObject automatically does resumable multipart operation. +// - For size input as -1 PutObject treats it as a stream and does multipart operation until +// input stream reaches EOF. +// +// NOTE: if you are using Google Cloud Storage. Then there is no resumable multipart +// upload support yet. Currently PutObject will behave like a single PUT operation and would +// only upload for file sizes upto maximum 5GB. (maximum limit for single PUT operation). +// +// For un-authenticated requests S3 doesn't allow multipart upload, so we fall back to single +// PUT operation. func (a API) PutObject(bucket, object, contentType string, size int64, data io.Reader) error { if err := invalidBucketError(bucket); err != nil { return err @@ -677,7 +688,7 @@ func (a API) PutObject(bucket, object, contentType string, size int64, data io.R return nil } switch { - case size < minimumPartSize && size > 0: + case size < minimumPartSize && size >= 0: // Single Part use case, use PutObject directly. for part := range chopper(data, minimumPartSize, nil) { if part.Err != nil { @@ -697,7 +708,7 @@ func (a API) PutObject(bucket, object, contentType string, size int64, data io.R } return nil } - default: + case size >= minimumPartSize || size == -1: var inProgress bool var inProgressUploadID string for mpUpload := range a.listMultipartUploadsRecursive(bucket, object) { diff --git a/vendor/vendor.json b/vendor/vendor.json index 8801b0d0..c6cd0c26 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -29,8 +29,8 @@ }, { "path": "github.com/minio/minio-go", - "revision": "5eb302c71339c00f6a895f2dca133395227c0fae", - "revisionTime": "2015-11-13T19:53:11-08:00" + "revision": "f3e8175c352db0fe318c1e8db19f167fa83c60e3", + "revisionTime": "2015-11-14T23:15:05-08:00" }, { "path": "github.com/minio/minio-xl/pkg/probe",