Skip to content

Commit

Permalink
Disable chunk encoding for put requests to Google Cloud Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkvi authored and Inkvi committed Oct 7, 2024
1 parent bb354f7 commit f65dc06
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion store/precomputed_key/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"errors"
"io"
"net/url"
"path"
"time"

Expand All @@ -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 (
Expand Down Expand Up @@ -97,7 +99,16 @@ 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{})
endpointURL, err := url.Parse(s.cfg.Endpoint)
if err != nil {
return err
}

putObjectOptions := minio.PutObjectOptions{}
if s3utils.IsGoogleEndpoint(*endpointURL) {
putObjectOptions.DisableContentSha256 = true // Avoid chunk signatures on GCS: https://github.com/minio/minio-go/issues/1922
}
_, err = s.client.PutObject(ctx, s.cfg.Bucket, path.Join(s.cfg.Path, hex.EncodeToString(key)), bytes.NewReader(value), int64(len(value)), putObjectOptions)
if err != nil {
return err
}
Expand Down

0 comments on commit f65dc06

Please sign in to comment.