feat: set raw url in get resp
This commit is contained in:
parent
40548926e6
commit
bf950ee6e1
@ -1,13 +1,12 @@
|
|||||||
package driver
|
package driver
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Name string
|
Name string
|
||||||
LocalSort bool
|
LocalSort bool
|
||||||
OnlyLocal bool
|
OnlyLocal bool
|
||||||
OnlyProxy bool
|
OnlyProxy bool
|
||||||
NoNeedSetLink bool
|
NoCache bool
|
||||||
NoCache bool
|
NoUpload bool
|
||||||
NoUpload bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) MustProxy() bool {
|
func (c Config) MustProxy() bool {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/alist-org/alist/v3/internal/sign"
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/db"
|
"github.com/alist-org/alist/v3/internal/db"
|
||||||
@ -146,6 +149,28 @@ func FsGet(c *gin.Context) {
|
|||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
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{
|
common.SuccessResp(c, FsGetResp{
|
||||||
ObjResp: ObjResp{
|
ObjResp: ObjResp{
|
||||||
Name: obj.GetName(),
|
Name: obj.GetName(),
|
||||||
@ -154,6 +179,6 @@ func FsGet(c *gin.Context) {
|
|||||||
Modified: obj.ModTime(),
|
Modified: obj.ModTime(),
|
||||||
Sign: common.Sign(obj),
|
Sign: common.Sign(obj),
|
||||||
},
|
},
|
||||||
// TODO: set raw url
|
RawURL: rawURL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user