mirror of https://github.com/Xhofe/alist
feat: add provider to obj get api
parent
61fa6f38a8
commit
d6437a337f
|
@ -16,7 +16,7 @@ func GetBaseUrl(r *http.Request) string {
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
}
|
}
|
||||||
if baseUrl == "" {
|
if baseUrl == "" {
|
||||||
baseUrl = fmt.Sprintf("%s//%s", protocol, r.Host)
|
baseUrl = fmt.Sprintf("%s://%s", protocol, r.Host)
|
||||||
}
|
}
|
||||||
strings.TrimSuffix(baseUrl, "/")
|
strings.TrimSuffix(baseUrl, "/")
|
||||||
return baseUrl
|
return baseUrl
|
||||||
|
|
|
@ -197,9 +197,10 @@ type FsGetOrLinkReq struct {
|
||||||
|
|
||||||
type FsGetResp struct {
|
type FsGetResp struct {
|
||||||
ObjResp
|
ObjResp
|
||||||
RawURL string `json:"raw_url"`
|
RawURL string `json:"raw_url"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
Related []string `json:"related"`
|
Provider string `json:"provider"`
|
||||||
|
Related []string `json:"related"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func FsGet(c *gin.Context) {
|
func FsGet(c *gin.Context) {
|
||||||
|
@ -228,12 +229,21 @@ func FsGet(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var rawURL string
|
var rawURL string
|
||||||
|
|
||||||
|
storage, err := fs.GetStorage(req.Path)
|
||||||
|
provider := "unknown"
|
||||||
|
if err == nil {
|
||||||
|
provider = storage.Config().Name
|
||||||
|
}
|
||||||
// file have raw url
|
// file have raw url
|
||||||
if !obj.IsDir() {
|
if !obj.IsDir() {
|
||||||
if u, ok := obj.(model.URL); ok {
|
if u, ok := obj.(model.URL); ok {
|
||||||
rawURL = u.URL()
|
rawURL = u.URL()
|
||||||
} else {
|
} else {
|
||||||
storage, _ := fs.GetStorage(req.Path)
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 500)
|
||||||
|
return
|
||||||
|
}
|
||||||
if storage.Config().MustProxy() || storage.GetStorage().WebProxy {
|
if storage.Config().MustProxy() || storage.GetStorage().WebProxy {
|
||||||
if storage.GetStorage().DownProxyUrl != "" {
|
if storage.GetStorage().DownProxyUrl != "" {
|
||||||
rawURL = fmt.Sprintf("%s%s?sign=%s", strings.Split(storage.GetStorage().DownProxyUrl, "\n")[0], req.Path, sign.Sign(obj.GetName()))
|
rawURL = fmt.Sprintf("%s%s?sign=%s", strings.Split(storage.GetStorage().DownProxyUrl, "\n")[0], req.Path, sign.Sign(obj.GetName()))
|
||||||
|
@ -265,9 +275,10 @@ func FsGet(c *gin.Context) {
|
||||||
Sign: common.Sign(obj),
|
Sign: common.Sign(obj),
|
||||||
Type: utils.GetFileType(obj.GetName()),
|
Type: utils.GetFileType(obj.GetName()),
|
||||||
},
|
},
|
||||||
RawURL: rawURL,
|
RawURL: rawURL,
|
||||||
Readme: getReadme(meta, req.Path),
|
Readme: getReadme(meta, req.Path),
|
||||||
Related: related,
|
Provider: provider,
|
||||||
|
Related: related,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue