Skip to content

Commit

Permalink
feat(s3): optional remove bucket name from path (close #4069)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Apr 9, 2023
1 parent cc43238 commit 75fd0ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/s3/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net/url"
stdpath "path"
"strings"
"time"

"github.com/alist-org/alist/v3/internal/driver"
Expand Down Expand Up @@ -75,6 +76,9 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
if d.CustomHost != "" {
err = req.Build()
link = req.HTTPRequest.URL.String()
if d.RemoveBucket {
link = strings.Replace(link, "/"+d.Bucket, "", 1)
}
} else {
link, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
}
Expand Down
1 change: 1 addition & 0 deletions drivers/s3/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Addition struct {
Placeholder string `json:"placeholder"`
ForcePathStyle bool `json:"force_path_style"`
ListObjectVersion string `json:"list_object_version" type:"select" options:"v1,v2" default:"v1"`
RemoveBucket bool `json:"remove_bucket" help:"Remove bucket name from path when using custom host."`
}

var config = driver.Config{
Expand Down

0 comments on commit 75fd0ee

Please sign in to comment.