This commit is contained in:
parent
bb305eab9e
commit
f3d123ee3b
2 changed files with 14 additions and 6 deletions
|
|
@ -21,7 +21,7 @@ type Deps struct {
|
|||
|
||||
func NewHandler(deps Deps) *Handler {
|
||||
packageBucketName := "user-merch-images"
|
||||
expires := time.Minute * 1
|
||||
expires := time.Minute * 5
|
||||
|
||||
r := NewRepo(deps.DB)
|
||||
s := newService(r, deps.Media, packageBucketName, expires)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -46,12 +45,21 @@ func (s *Service) Get(ctx context.Context, bucket, object string, expires time.D
|
|||
return "", err
|
||||
}
|
||||
|
||||
link := presigned.String()
|
||||
if s.domain != "" {
|
||||
link = strings.Replace(link, fmt.Sprintf("http://%s", s.endpoint), s.domain, 1)
|
||||
u, err := url.Parse(presigned.String())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return link, nil
|
||||
if s.domain != "" {
|
||||
domainURL, err := url.Parse(s.domain)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid domain URL: %w", err)
|
||||
}
|
||||
u.Scheme = domainURL.Scheme
|
||||
u.Host = domainURL.Host
|
||||
}
|
||||
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func (s *Service) Delete(ctx context.Context, bucket, object string) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue