Skip to content

Commit

Permalink
Merge pull request #50 from udf2457/main
Browse files Browse the repository at this point in the history
Update s3.go to enable content-md5
  • Loading branch information
ahouene authored Sep 28, 2023
2 parents 5fc6dd1 + 9639fad commit 3666dc4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions backends/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
// DefaultSecretsRefreshInterval is the default value for RefreshSecrets.
// It should not be too high so as to retrieve secrets regularly.
DefaultSecretsRefreshInterval = 15 * time.Second
// DefaultDisableContentMd5 : disable sending the Content-MD5 header
DefaultDisableContentMd5 = false
)

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

// DisableContentMd5 defines whether to disable sending the Content-MD5 header
DisableContentMd5 bool `yaml:"disable_send_content_md5"`

// TLS allows customising the TLS configuration
// See https://github.com/PowerDNS/go-tlsconfig for the available options
TLS tlsconfig.Config `yaml:"tls"`
Expand Down Expand Up @@ -262,9 +267,14 @@ func (b *Backend) doStore(ctx context.Context, name string, data []byte) (minio.
metricCalls.WithLabelValues("store").Inc()
metricLastCallTimestamp.WithLabelValues("store").SetToCurrentTime()

info, err := b.client.PutObject(ctx, b.opt.Bucket, name, bytes.NewReader(data), int64(len(data)), minio.PutObjectOptions{
putObjectOptions := minio.PutObjectOptions{
NumThreads: 3,
})
}
if !b.opt.DisableContentMd5 {
putObjectOptions.SendContentMd5 = true
}

info, err := b.client.PutObject(ctx, b.opt.Bucket, name, bytes.NewReader(data), int64(len(data)), putObjectOptions)
if err != nil {
metricCallErrors.WithLabelValues("store").Inc()
}
Expand Down

0 comments on commit 3666dc4

Please sign in to comment.