Skip to content

Commit a39268a

Browse files
committed
fix(sponsor-panel): set public-read ACL on S3 uploads for Tigris
Uploaded sponsor logos need to be publicly accessible via t3.storage.dev, which requires the object ACL to be set to public-read.
1 parent a6f33fd commit a39268a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/sponsor-panel/handlers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313

1414
"github.com/aws/aws-sdk-go-v2/service/s3"
15+
"github.com/aws/aws-sdk-go-v2/service/s3/types"
1516
"github.com/google/go-github/v82/github"
1617
"github.com/google/uuid"
1718

@@ -197,11 +198,13 @@ func (s *Server) logoHandler(w http.ResponseWriter, r *http.Request) {
197198
"key", s3Key,
198199
"content_type", contentType)
199200

201+
acl := types.ObjectCannedACLPublicRead
200202
putInput := &s3.PutObjectInput{
201203
Bucket: &s.bucketName,
202204
Key: &s3Key,
203205
Body: bytes.NewReader(fileData),
204206
ContentType: &contentType,
207+
ACL: acl,
205208
}
206209

207210
_, err := s.s3Client.PutObject(r.Context(), putInput)
@@ -211,7 +214,7 @@ func (s *Server) logoHandler(w http.ResponseWriter, r *http.Request) {
211214
return
212215
}
213216

214-
logoURL = fmt.Sprintf("https://%s.s3.amazonaws.com/%s", s.bucketName, s3Key)
217+
logoURL = fmt.Sprintf("https://%s.t3.storage.dev/%s", s.bucketName, s3Key)
215218
slog.Info("logoHandler: uploaded to S3",
216219
"user_id", user.ID,
217220
"url", logoURL,

0 commit comments

Comments
 (0)