Skip to content

Commit

Permalink
Fix file fetch in attachments failing for signed URLs. Closes #1499.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Sep 19, 2023
1 parent 8f2a08b commit 04e571d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/media/providers/s3/s3.go
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/url"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -107,10 +108,16 @@ func (c *Client) GetURL(name string) string {
}

// GetBlob reads a file from S3 and returns the raw bytes.
func (c *Client) GetBlob(url string) ([]byte, error) {
func (c *Client) GetBlob(uurl string) ([]byte, error) {
if p, err := url.Parse(uurl); err != nil {
uurl = filepath.Base(uurl)
} else {
uurl = filepath.Base(p.Path)
}

file, err := c.s3.FileDownload(simples3.DownloadInput{
Bucket: c.opts.Bucket,
ObjectKey: c.makeBucketPath(filepath.Base(url)),
ObjectKey: c.makeBucketPath(filepath.Base(uurl)),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 04e571d

Please sign in to comment.