Skip to content

Commit 9656534

Browse files
authored
Add PutObject CRC & trailing checksum tests (#1817)
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.
1 parent b7cf0a8 commit 9656534

File tree

3 files changed

+378
-1
lines changed

3 files changed

+378
-1
lines changed

api-put-object-streaming.go

+12
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,17 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
742742
// Set headers.
743743
customHeader := opts.Header()
744744

745+
// Add CRC when client supports it, MD5 is not set, not Google and we don't add SHA256 to chunks.
746+
addCrc := c.trailingHeaderSupport && md5Base64 == "" && !s3utils.IsGoogleEndpoint(*c.endpointURL) && (opts.DisableContentSha256 || c.secure)
747+
748+
if addCrc {
749+
// If user has added checksums, don't add them ourselves.
750+
for k := range opts.UserMetadata {
751+
if strings.HasPrefix(strings.ToLower(k), "x-amz-checksum-") {
752+
addCrc = false
753+
}
754+
}
755+
}
745756
// Populate request metadata.
746757
reqMetadata := requestMetadata{
747758
bucketName: bucketName,
@@ -752,6 +763,7 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
752763
contentMD5Base64: md5Base64,
753764
contentSHA256Hex: sha256Hex,
754765
streamSha256: !opts.DisableContentSha256,
766+
addCrc: addCrc,
755767
}
756768
if opts.Internal.SourceVersionID != "" {
757769
if opts.Internal.SourceVersionID != nullVersionID {

0 commit comments

Comments
 (0)