Skip to content

Commit 9639fad

Browse files
authored
Update s3.go to enable content-md5
Add call to minio putObjectOptions.SendContentMd5 to enable sending of content-md5 header for end-to-end integrity checking.
1 parent 5fc6dd1 commit 9639fad

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

backends/s3/s3.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const (
4040
// DefaultSecretsRefreshInterval is the default value for RefreshSecrets.
4141
// It should not be too high so as to retrieve secrets regularly.
4242
DefaultSecretsRefreshInterval = 15 * time.Second
43+
// DefaultDisableContentMd5 : disable sending the Content-MD5 header
44+
DefaultDisableContentMd5 = false
4345
)
4446

4547
// Options describes the storage options for the S3 backend
@@ -82,6 +84,9 @@ type Options struct {
8284
// or "https://s3.amazonaws.com" for AWS S3.
8385
EndpointURL string `yaml:"endpoint_url"`
8486

87+
// DisableContentMd5 defines whether to disable sending the Content-MD5 header
88+
DisableContentMd5 bool `yaml:"disable_send_content_md5"`
89+
8590
// TLS allows customising the TLS configuration
8691
// See https://github.com/PowerDNS/go-tlsconfig for the available options
8792
TLS tlsconfig.Config `yaml:"tls"`
@@ -262,9 +267,14 @@ func (b *Backend) doStore(ctx context.Context, name string, data []byte) (minio.
262267
metricCalls.WithLabelValues("store").Inc()
263268
metricLastCallTimestamp.WithLabelValues("store").SetToCurrentTime()
264269

265-
info, err := b.client.PutObject(ctx, b.opt.Bucket, name, bytes.NewReader(data), int64(len(data)), minio.PutObjectOptions{
270+
putObjectOptions := minio.PutObjectOptions{
266271
NumThreads: 3,
267-
})
272+
}
273+
if !b.opt.DisableContentMd5 {
274+
putObjectOptions.SendContentMd5 = true
275+
}
276+
277+
info, err := b.client.PutObject(ctx, b.opt.Bucket, name, bytes.NewReader(data), int64(len(data)), putObjectOptions)
268278
if err != nil {
269279
metricCallErrors.WithLabelValues("store").Inc()
270280
}

0 commit comments

Comments
 (0)