From cd84841e1e75a6c245b8a8e9c862703c6b2597db Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 7 Dec 2021 15:35:38 -0800 Subject: [PATCH] docs: clarify PutObject with '-1' content-length fixes #1478 --- api-put-object.go | 15 +++++++++++---- pkg/policy/bucket-policy-condition_test.go | 4 +--- pkg/policy/bucket-policy.go | 3 +-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/api-put-object.go b/api-put-object.go index fb61b407a..e8a964e2a 100644 --- a/api-put-object.go +++ b/api-put-object.go @@ -214,13 +214,20 @@ func (a completedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].Part // // You must have WRITE permissions on a bucket to create an object. // -// - For size smaller than 128MiB PutObject automatically does a -// single atomic Put operation. -// - For size larger than 128MiB PutObject automatically does a -// multipart Put operation. +// - For size smaller than 16MiB PutObject automatically does a +// single atomic PUT operation. +// +// - For size larger than 16MiB PutObject automatically does a +// multipart upload operation. +// // - For size input as -1 PutObject does a multipart Put operation // until input stream reaches EOF. Maximum object size that can // be uploaded through this operation will be 5TiB. +// +// WARNING: Passing down '-1' will use memory and these cannot +// be reused for best outcomes for PutObject(), pass the size always. +// +// NOTE: Upon errors during upload multipart operation is entirely aborted. func (c *Client) PutObject(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts PutObjectOptions) (info UploadInfo, err error) { if objectSize < 0 && opts.DisableMultipart { diff --git a/pkg/policy/bucket-policy-condition_test.go b/pkg/policy/bucket-policy-condition_test.go index 1fc154868..53e0b7e8b 100644 --- a/pkg/policy/bucket-policy-condition_test.go +++ b/pkg/policy/bucket-policy-condition_test.go @@ -18,14 +18,12 @@ package policy import ( + "encoding/json" "testing" - jsoniter "github.com/json-iterator/go" "github.com/minio/minio-go/v7/pkg/set" ) -var json = jsoniter.ConfigCompatibleWithStandardLibrary - // ConditionKeyMap.Add() is called and the result is validated. func TestConditionKeyMapAdd(t *testing.T) { condKeyMap := make(ConditionKeyMap) diff --git a/pkg/policy/bucket-policy.go b/pkg/policy/bucket-policy.go index bb8c51b07..6ad609932 100644 --- a/pkg/policy/bucket-policy.go +++ b/pkg/policy/bucket-policy.go @@ -18,11 +18,11 @@ package policy import ( + "encoding/json" "errors" "reflect" "strings" - jsoniter "github.com/json-iterator/go" "github.com/minio/minio-go/v7/pkg/set" ) @@ -89,7 +89,6 @@ type User struct { // User string but it can also take a string. func (u *User) UnmarshalJSON(data []byte) error { // Try to unmarshal data in a struct equal to User, - var json = jsoniter.ConfigCompatibleWithStandardLibrary // to avoid infinite recursive call of this function type AliasUser User var au AliasUser