mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-21 20:18:47 +08:00
feat: set raw url in get resp
This commit is contained in:
parent
40548926e6
commit
bf950ee6e1
@ -1,13 +1,12 @@
|
||||
package driver
|
||||
|
||||
type Config struct {
|
||||
Name string
|
||||
LocalSort bool
|
||||
OnlyLocal bool
|
||||
OnlyProxy bool
|
||||
NoNeedSetLink bool
|
||||
NoCache bool
|
||||
NoUpload bool
|
||||
Name string
|
||||
LocalSort bool
|
||||
OnlyLocal bool
|
||||
OnlyProxy bool
|
||||
NoCache bool
|
||||
NoUpload bool
|
||||
}
|
||||
|
||||
func (c Config) MustProxy() bool {
|
||||
|
@ -1,7 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/alist-org/alist/v3/internal/sign"
|
||||
stdpath "path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
@ -146,6 +149,28 @@ func FsGet(c *gin.Context) {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
var rawURL string
|
||||
// obj have raw url
|
||||
if u, ok := obj.(model.URL); ok {
|
||||
rawURL = u.URL()
|
||||
} else {
|
||||
account, _ := fs.GetAccount(req.Path)
|
||||
if account.Config().MustProxy() || account.GetAccount().WebProxy {
|
||||
if account.GetAccount().DownProxyUrl != "" {
|
||||
rawURL = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.GetAccount().DownProxyUrl, "\n")[0], req.Path, sign.Sign(obj.GetName()))
|
||||
} else {
|
||||
rawURL = fmt.Sprintf("%s/p%s?sign=%s", common.GetBaseUrl(c.Request), req.Path, sign.Sign(obj.GetName()))
|
||||
}
|
||||
} else {
|
||||
// if account is not proxy, use raw url by fs.Link
|
||||
link, _, err := fs.Link(c, req.Path, model.LinkArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
rawURL = link.URL
|
||||
}
|
||||
}
|
||||
common.SuccessResp(c, FsGetResp{
|
||||
ObjResp: ObjResp{
|
||||
Name: obj.GetName(),
|
||||
@ -154,6 +179,6 @@ func FsGet(c *gin.Context) {
|
||||
Modified: obj.ModTime(),
|
||||
Sign: common.Sign(obj),
|
||||
},
|
||||
// TODO: set raw url
|
||||
RawURL: rawURL,
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user