mirror of https://github.com/Xhofe/alist
feat(s3): optional remove bucket name from path (close #4069)
parent
cc43238bd1
commit
75fd0ee185
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
|
@ -75,6 +76,9 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
|
||||||
if d.CustomHost != "" {
|
if d.CustomHost != "" {
|
||||||
err = req.Build()
|
err = req.Build()
|
||||||
link = req.HTTPRequest.URL.String()
|
link = req.HTTPRequest.URL.String()
|
||||||
|
if d.RemoveBucket {
|
||||||
|
link = strings.Replace(link, "/"+d.Bucket, "", 1)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
link, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
|
link, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ type Addition struct {
|
||||||
Placeholder string `json:"placeholder"`
|
Placeholder string `json:"placeholder"`
|
||||||
ForcePathStyle bool `json:"force_path_style"`
|
ForcePathStyle bool `json:"force_path_style"`
|
||||||
ListObjectVersion string `json:"list_object_version" type:"select" options:"v1,v2" default:"v1"`
|
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{
|
var config = driver.Config{
|
||||||
|
|
Loading…
Reference in New Issue