Fix file fetch in attachments failing for signed URLs. Closes #1499.
This commit is contained in:
parent
8f2a08b8db
commit
04e571d43a
1 changed files with 9 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue