diff --git a/store/precomputed_key/s3/s3.go b/store/precomputed_key/s3/s3.go index 16bccf58..eb8db664 100644 --- a/store/precomputed_key/s3/s3.go +++ b/store/precomputed_key/s3/s3.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "io" + "net/url" "path" "time" @@ -14,6 +15,7 @@ import ( "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + "github.com/minio/minio-go/v7/pkg/s3utils" ) const ( @@ -50,12 +52,22 @@ type Config struct { } type Store struct { - cfg Config - client *minio.Client - stats *store.Stats + cfg Config + client *minio.Client + putObjectOptions minio.PutObjectOptions + stats *store.Stats } func NewS3(cfg Config) (*Store, error) { + endpointURL, err := url.Parse(cfg.Endpoint) + if err != nil { + return nil, err + } + putObjectOptions := minio.PutObjectOptions{} + if s3utils.IsGoogleEndpoint(*endpointURL) { + putObjectOptions.DisableContentSha256 = true // Avoid chunk signatures on GCS: https://github.com/minio/minio-go/issues/1922 + } + client, err := minio.New(cfg.Endpoint, &minio.Options{ Creds: creds(cfg), Secure: cfg.EnableTLS, @@ -65,8 +77,9 @@ func NewS3(cfg Config) (*Store, error) { } return &Store{ - cfg: cfg, - client: client, + cfg: cfg, + client: client, + putObjectOptions: putObjectOptions, stats: &store.Stats{ Entries: 0, Reads: 0, @@ -97,7 +110,7 @@ func (s *Store) Get(ctx context.Context, key []byte) ([]byte, error) { } func (s *Store) Put(ctx context.Context, key []byte, value []byte) error { - _, err := s.client.PutObject(ctx, s.cfg.Bucket, path.Join(s.cfg.Path, hex.EncodeToString(key)), bytes.NewReader(value), int64(len(value)), minio.PutObjectOptions{}) + _, err := s.client.PutObject(ctx, s.cfg.Bucket, path.Join(s.cfg.Path, hex.EncodeToString(key)), bytes.NewReader(value), int64(len(value)), s.putObjectOptions) if err != nil { return err }