Skip to content

Commit

Permalink
Add PutObject CRC & trailing checksum tests (#1817)
Browse files Browse the repository at this point in the history
Add tests for minio/minio#16484 (required to pass)

PutObject will now add CRC when client supports it, MD5 is not set, not Google and we don't add SHA256 to chunks.
  • Loading branch information
klauspost committed May 25, 2023
1 parent b7cf0a8 commit 9656534
Show file tree
Hide file tree
Showing 3 changed files with 378 additions and 1 deletion.
12 changes: 12 additions & 0 deletions api-put-object-streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,17 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
// Set headers.
customHeader := opts.Header()

// Add CRC when client supports it, MD5 is not set, not Google and we don't add SHA256 to chunks.
addCrc := c.trailingHeaderSupport && md5Base64 == "" && !s3utils.IsGoogleEndpoint(*c.endpointURL) && (opts.DisableContentSha256 || c.secure)

if addCrc {
// If user has added checksums, don't add them ourselves.
for k := range opts.UserMetadata {
if strings.HasPrefix(strings.ToLower(k), "x-amz-checksum-") {
addCrc = false
}
}
}
// Populate request metadata.
reqMetadata := requestMetadata{
bucketName: bucketName,
Expand All @@ -752,6 +763,7 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
contentMD5Base64: md5Base64,
contentSHA256Hex: sha256Hex,
streamSha256: !opts.DisableContentSha256,
addCrc: addCrc,
}
if opts.Internal.SourceVersionID != "" {
if opts.Internal.SourceVersionID != nullVersionID {
Expand Down

0 comments on commit 9656534

Please sign in to comment.