~netlandish/gobwebs

784ef6266c5506753e8eb35a51744d07139a160d — Peter Sanchez 19 days ago dc3a213 master
Removing using ACLs by default for s3 storage. These are no longer recommended
1 files changed, 13 insertions(+), 10 deletions(-)

M storage/s3.go
M storage/s3.go => storage/s3.go +13 -10
@@ 9,10 9,11 @@ import (

	"github.com/minio/minio-go/v7"
	"github.com/minio/minio-go/v7/pkg/credentials"
	"golang.org/x/exp/slices"
)

// https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
var s3CannedACL []string = []string{
var s3CannedACL = []string{
	"private",
	"public-read",
	"public-read-write",


@@ 59,20 60,20 @@ func NewS3Service(endpoint, bucket string, opts *S3Options) (*S3Service, error) 
		Client: client,
		Prefix: opts.Prefix,
	}
	if opts.ACL == "" {
		opts.ACL = "private"
	if opts.ACL != "" {
		err = service.SetACL(opts.ACL)
		if err != nil {
			return nil, err
		}
	}
	service.SetACL(opts.ACL)
	return service, nil
}

// SetACL sets the s3 acl header to be used for future ops.
func (s *S3Service) SetACL(acl string) error {
	for _, x := range s3CannedACL {
		if x == acl {
			s.perm = acl
			return nil
		}
	if slices.Contains(s3CannedACL, acl) {
		s.perm = acl
		return nil
	}
	return fmt.Errorf("Provided ACL '%s' is invalid", acl)
}


@@ 134,7 135,9 @@ func (s *S3Service) PutObject(ctx context.Context, path string, content io.Reade
	var data bytes.Buffer
	fullpath := pathutil.Join(s.Prefix, path)
	meta := make(map[string]string)
	meta["x-amz-acl"] = s.perm
	if s.perm != "" {
		meta["x-amz-acl"] = s.perm
	}
	_, err := io.Copy(&data, content)
	if err != nil {
		return err