diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 9c4bb8af..022219c7 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -987,13 +987,19 @@ func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metada if lockModeStr != "" { opts.Mode = &lockMode + opts.SendContentMd5 = true } if lh, ok := metadata[AmzObjectLockLegalHold]; ok { delete(metadata, AmzObjectLockLegalHold) opts.LegalHold = minio.LegalHoldStatus(strings.ToUpper(lh)) + opts.SendContentMd5 = true + } + if opts.LegalHold == "" && opts.Mode == nil { + if _, _, _, err := c.api.GetBucketObjectLockConfig(bucket); err == nil { + opts.SendContentMd5 = true + } } - n, e := c.api.PutObjectWithContext(ctx, bucket, object, reader, size, opts) if e != nil { errResponse := minio.ToErrorResponse(e) diff --git a/cmd/cp-main.go b/cmd/cp-main.go index 850ba33e..9fa25983 100644 --- a/cmd/cp-main.go +++ b/cmd/cp-main.go @@ -478,7 +478,7 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p cpURLs.TargetContent.RetentionEnabled = true } cpURLs.TargetContent.RetentionDuration = session.Header.CommandStringFlags[rdFlag] - cpURLs.TargetContent.LegalHold = session.Header.CommandStringFlags[lhFlag] + cpURLs.TargetContent.LegalHold = strings.ToUpper(session.Header.CommandStringFlags[lhFlag]) if cpURLs.TargetContent.LegalHold != "" { cpURLs.TargetContent.LegalHoldEnabled = true } @@ -491,7 +491,7 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p cpURLs.TargetContent.RetentionDuration = rd } if lh := cli.String(lhFlag); lh != "" { - cpURLs.TargetContent.LegalHold = lh + cpURLs.TargetContent.LegalHold = strings.ToUpper(lh) cpURLs.TargetContent.LegalHoldEnabled = true } } @@ -642,7 +642,7 @@ func mainCopy(ctx *cli.Context) error { storageClass := ctx.String("storage-class") retentionMode := ctx.String(rmFlag) retentionDuration := ctx.String(rdFlag) - legalHold := ctx.String(lhFlag) + legalHold := strings.ToUpper(ctx.String(lhFlag)) sseKeys := os.Getenv("MC_ENCRYPT_KEY") if key := ctx.String("encrypt-key"); key != "" { sseKeys = key