Skip to content

Commit

Permalink
feat(s3): support custom host presign (#7699 close #7696)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirCute authored Dec 25, 2024
1 parent 40b0e66 commit 221cdf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/s3/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
var link model.Link
var err error
if d.CustomHost != "" {
err = req.Build()
link.URL = req.HTTPRequest.URL.String()
if d.EnableCustomHostPresign {
link.URL, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
} else {
err = req.Build()
link.URL = req.HTTPRequest.URL.String()
}
if d.RemoveBucket {
link.URL = strings.Replace(link.URL, "/"+d.Bucket, "", 1)
}
Expand Down
1 change: 1 addition & 0 deletions drivers/s3/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Addition struct {
SecretAccessKey string `json:"secret_access_key" required:"true"`
SessionToken string `json:"session_token"`
CustomHost string `json:"custom_host"`
EnableCustomHostPresign bool `json:"enable_custom_host_presign"`
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
Placeholder string `json:"placeholder"`
ForcePathStyle bool `json:"force_path_style"`
Expand Down

0 comments on commit 221cdf3

Please sign in to comment.