Skip to content

Commit

Permalink
feat(s3): using internal download method in proxy (#6988)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 authored Aug 14, 2024
1 parent 3dc250c commit 94937db
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drivers/s3/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/alist-org/alist/v3/server/common"
"io"
"net/url"
stdpath "path"
Expand Down Expand Up @@ -95,23 +96,27 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
input.ResponseContentDisposition = &disposition
}
req, _ := d.linkClient.GetObjectRequest(input)
var link string
var link model.Link
var err error
if d.CustomHost != "" {
err = req.Build()
link = req.HTTPRequest.URL.String()
link.URL = req.HTTPRequest.URL.String()
if d.RemoveBucket {
link = strings.Replace(link, "/"+d.Bucket, "", 1)
link.URL = strings.Replace(link.URL, "/"+d.Bucket, "", 1)
}
} else {
link, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
if common.ShouldProxy(d, filename) {
err = req.Sign()
link.URL = req.HTTPRequest.URL.String()
link.Header = req.HTTPRequest.Header
} else {
link.URL, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
}
}
if err != nil {
return nil, err
}
return &model.Link{
URL: link,
}, nil
return &link, nil
}

func (d *S3) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
Expand Down

0 comments on commit 94937db

Please sign in to comment.