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"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -107,10 +108,16 @@ func (c *Client) GetURL(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlob reads a file from S3 and returns the raw bytes.
|
// 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{
|
file, err := c.s3.FileDownload(simples3.DownloadInput{
|
||||||
Bucket: c.opts.Bucket,
|
Bucket: c.opts.Bucket,
|
||||||
ObjectKey: c.makeBucketPath(filepath.Base(url)),
|
ObjectKey: c.makeBucketPath(filepath.Base(uurl)),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue