Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(s3): support custom host presign #7699

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(s3): support custom host presign
KirCute committed Dec 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0b1df92794a39e566be7219adcb2ac92bdcb33cc
8 changes: 6 additions & 2 deletions drivers/s3/driver.go
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions drivers/s3/meta.go
Original file line number Diff line number Diff line change
@@ -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"`