feat(s3): support custom host presign (#7699 close #7696)

pull/7673/head
KirCute_ECT 2024-12-25 21:13:23 +08:00 committed by GitHub
parent 40b0e66efe
commit 221cdf3611
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -99,8 +99,12 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
var link model.Link var link model.Link
var err error var err error
if d.CustomHost != "" { if d.CustomHost != "" {
if d.EnableCustomHostPresign {
link.URL, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
} else {
err = req.Build() err = req.Build()
link.URL = req.HTTPRequest.URL.String() link.URL = req.HTTPRequest.URL.String()
}
if d.RemoveBucket { if d.RemoveBucket {
link.URL = strings.Replace(link.URL, "/"+d.Bucket, "", 1) link.URL = strings.Replace(link.URL, "/"+d.Bucket, "", 1)
} }

View File

@ -14,6 +14,7 @@ type Addition struct {
SecretAccessKey string `json:"secret_access_key" required:"true"` SecretAccessKey string `json:"secret_access_key" required:"true"`
SessionToken string `json:"session_token"` SessionToken string `json:"session_token"`
CustomHost string `json:"custom_host"` CustomHost string `json:"custom_host"`
EnableCustomHostPresign bool `json:"enable_custom_host_presign"`
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"` SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
Placeholder string `json:"placeholder"` Placeholder string `json:"placeholder"`
ForcePathStyle bool `json:"force_path_style"` ForcePathStyle bool `json:"force_path_style"`