Skip to content

Commit

Permalink
fix: check public URL before presigned URL generation (#1148)
Browse files Browse the repository at this point in the history
Fixes #1141
  • Loading branch information
rhnvrm committed Jan 16, 2023
1 parent 66c81c8 commit 72d22d4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/media/providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ func (c *Client) Put(name string, cType string, file io.ReadSeeker) (string, err

// Get accepts the filename of the object stored and retrieves from S3.
func (c *Client) Get(name string) string {
// Generate a private S3 pre-signed URL if it's a private bucket.
if c.opts.BucketType == "private" {
// Generate a private S3 pre-signed URL if it's a private bucket, and there
// is no public URL provided.
if c.opts.BucketType == "private" && c.opts.PublicURL == "" {
u := c.s3.GeneratePresignedURL(simples3.PresignedInput{
Bucket: c.opts.Bucket,
ObjectKey: c.makeBucketPath(name),
Expand All @@ -93,7 +94,8 @@ func (c *Client) Get(name string) string {
return u
}

// Generate a public S3 URL if it's a public bucket.
// Generate a public S3 URL if it's a public bucket or a public URL is
// provided.
return c.makeFileURL(name)
}

Expand Down

0 comments on commit 72d22d4

Please sign in to comment.