func (c Client) PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,
	opts PutObjectOptions) (n int64, err error) {
	if objectSize < 0 && opts.DisableMultipart {
		return 0, errors.New("object size must be provided with disable multipart upload")
	}
	return c.PutObjectWithContext(context.Background(), bucketName, objectName, reader, objectSize, opts)
}
PutObject creates an object in a bucket.

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 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.
package minio
import (
	"bytes"
	"context"
	"encoding/base64"
	"errors"
	"fmt"
	"io"
	"net/http"
	"sort"
	"time"
	"github.com/minio/minio-go/v6/pkg/encrypt"
	"github.com/minio/minio-go/v6/pkg/s3utils"
	"golang.org/x/net/http/httpguts"
)
type PutObjectOptions struct {
	UserMetadata            map[string]string
	UserTags                map[string]string
	Progress                io.Reader
	ContentType             string
	ContentEncoding         string
	ContentDisposition      string
	ContentLanguage         string
	CacheControl            string
	Mode                    *RetentionMode
	RetainUntilDate         *time.Time
	ServerSideEncryption    encrypt.ServerSide
	NumThreads              uint
	StorageClass            string
	WebsiteRedirectLocation string
	PartSize                uint64
	LegalHold               LegalHoldStatus
	SendContentMd5          bool
	DisableMultipart        bool
}
func (opts PutObjectOptions) getNumThreads() (numThreads int) {
	if opts.NumThreads > 0 {
		numThreads = int(opts.NumThreads)
	} else {
		numThreads = totalWorkers
	}
	return
}
func (opts PutObjectOptions) Header() (header http.Header) {
	header = make(http.Header)
	contentType := opts.ContentType
	if contentType == "" {
		contentType = "application/octet-stream"
	}
	header.Set("Content-Type", contentType)
	if opts.ContentEncoding != "" {
		header.Set("Content-Encoding", opts.ContentEncoding)
	}
	if opts.ContentDisposition != "" {
		header.Set("Content-Disposition", opts.ContentDisposition)
	}
	if opts.ContentLanguage != "" {
		header.Set("Content-Language", opts.ContentLanguage)
	}
	if opts.CacheControl != "" {
		header.Set("Cache-Control", opts.CacheControl)
	}
	if opts.Mode != nil {
		header.Set(amzLockMode, opts.Mode.String())
	}
	if opts.RetainUntilDate != nil {
		header.Set("X-Amz-Object-Lock-Retain-Until-Date", opts.RetainUntilDate.Format(time.RFC3339))
	}
	if opts.LegalHold != "" {
		header.Set(amzLegalHoldHeader, opts.LegalHold.String())
	}
	if opts.ServerSideEncryption != nil {
		opts.ServerSideEncryption.Marshal(header)
	}
	if opts.StorageClass != "" {
		header.Set(amzStorageClass, opts.StorageClass)
	}
	if opts.WebsiteRedirectLocation != "" {
		header.Set(amzWebsiteRedirectLocation, opts.WebsiteRedirectLocation)
	}
	if len(opts.UserTags) != 0 {
		header.Set(amzTaggingHeader, s3utils.TagEncode(opts.UserTags))
	}
	for k, v := range opts.UserMetadata {
		if !isAmzHeader(k) && !isStandardHeader(k) && !isStorageClassHeader(k) {
			header.Set("X-Amz-Meta-"+k, v)
		} else {
			header.Set(k, v)
		}
	}
	return
}
func (opts PutObjectOptions) validate() (err error) {
	for k, v := range opts.UserMetadata {
		if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) {
			return ErrInvalidArgument(k + " unsupported user defined metadata name")
		}
		if !httpguts.ValidHeaderFieldValue(v) {
			return ErrInvalidArgument(v + " unsupported user defined metadata value")
		}
	}
	if opts.Mode != nil {
		if !opts.Mode.IsValid() {
			return ErrInvalidArgument(opts.Mode.String() + " unsupported retention mode")
		}
	}
	if opts.LegalHold != "" && !opts.LegalHold.IsValid() {
		return ErrInvalidArgument(opts.LegalHold.String() + " unsupported legal-hold status")
	}
	return nil
}
type completedParts []CompletePart
func (a completedParts) Len() int           { return len(a) }
func (a completedParts) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a completedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].PartNumber }