mirror of https://github.com/Xhofe/alist
feat(onedrive): custom host for download link (close #5310)
parent
e8958019d9
commit
0fd51646f6
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/alist-org/alist/v3/drivers/base"
|
||||
|
@ -57,8 +58,17 @@ func (d *Onedrive) Link(ctx context.Context, file model.Obj, args model.LinkArgs
|
|||
if f.File == nil {
|
||||
return nil, errs.NotFile
|
||||
}
|
||||
u := f.Url
|
||||
if d.CustomHost != "" {
|
||||
_u, err := url.Parse(f.Url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_u.Host = d.CustomHost
|
||||
u = _u.String()
|
||||
}
|
||||
return &model.Link{
|
||||
URL: f.Url,
|
||||
URL: u,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ type Addition struct {
|
|||
RefreshToken string `json:"refresh_token" required:"true"`
|
||||
SiteId string `json:"site_id"`
|
||||
ChunkSize int64 `json:"chunk_size" type:"number" default:"5"`
|
||||
CustomHost string `json:"custom_host" help:"Custom host for onedrive download link"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/alist-org/alist/v3/drivers/base"
|
||||
|
@ -57,8 +58,17 @@ func (d *OnedriveAPP) Link(ctx context.Context, file model.Obj, args model.LinkA
|
|||
if f.File == nil {
|
||||
return nil, errs.NotFile
|
||||
}
|
||||
u := f.Url
|
||||
if d.CustomHost != "" {
|
||||
_u, err := url.Parse(f.Url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_u.Host = d.CustomHost
|
||||
u = _u.String()
|
||||
}
|
||||
return &model.Link{
|
||||
URL: f.Url,
|
||||
URL: u,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ type Addition struct {
|
|||
TenantID string `json:"tenant_id"`
|
||||
Email string `json:"email"`
|
||||
ChunkSize int64 `json:"chunk_size" type:"number" default:"5"`
|
||||
CustomHost string `json:"custom_host" help:"Custom host for onedrive download link"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
Loading…
Reference in New Issue