diff --git a/cmd/erasure-multipart.go b/cmd/erasure-multipart.go index 58b0f6719..4664fb8ad 100644 --- a/cmd/erasure-multipart.go +++ b/cmd/erasure-multipart.go @@ -452,7 +452,14 @@ func (er erasureObjects) PutObjectPart(ctx context.Context, bucket, object, uplo switch size := data.Size(); { case size == 0: buffer = make([]byte, 1) // Allocate atleast a byte to reach EOF - case size == -1 || size >= fi.Erasure.BlockSize: + case size == -1: + if size := data.ActualSize(); size > 0 && size < fi.Erasure.BlockSize { + buffer = make([]byte, data.ActualSize()+256, data.ActualSize()*2+512) + } else { + buffer = er.bp.Get() + defer er.bp.Put(buffer) + } + case size >= fi.Erasure.BlockSize: buffer = er.bp.Get() defer er.bp.Put(buffer) case size < fi.Erasure.BlockSize: diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 16e7f89a5..53ec298e0 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -683,7 +683,14 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st switch size := data.Size(); { case size == 0: buffer = make([]byte, 1) // Allocate atleast a byte to reach EOF - case size == -1 || size >= fi.Erasure.BlockSize: + case size == -1: + if size := data.ActualSize(); size > 0 && size < fi.Erasure.BlockSize { + buffer = make([]byte, data.ActualSize()+256, data.ActualSize()*2+512) + } else { + buffer = er.bp.Get() + defer er.bp.Put(buffer) + } + case size >= fi.Erasure.BlockSize: buffer = er.bp.Get() defer er.bp.Put(buffer) case size < fi.Erasure.BlockSize: