feat: optimize file operation interface (#2757)

* feat: optimize file operation interface

* chore: fix typo

Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
foxxorcat
2022-12-20 15:02:40 +08:00
committed by GitHub
parent e2bcca2fbd
commit 62a06fa0f9
13 changed files with 330 additions and 121 deletions

View File

@ -191,10 +191,7 @@ func pagination(objs []model.Obj, req *model.PageReq) (int, []model.Obj) {
func toObjsResp(objs []model.Obj, parent string, encrypt bool) []ObjResp {
var resp []ObjResp
for _, obj := range objs {
thumb := ""
if t, ok := obj.(model.Thumb); ok {
thumb = t.Thumb()
}
thumb, _ := model.GetThumb(obj)
resp = append(resp, ObjResp{
Name: obj.GetName(),
Size: obj.GetSize(),
@ -276,8 +273,8 @@ func FsGet(c *gin.Context) {
}
} else {
// file have raw url
if u, ok := obj.(model.URL); ok {
rawURL = u.URL()
if url, ok := model.GetUrl(obj); ok {
rawURL = url
} else {
// if storage is not proxy, use raw url by fs.Link
link, _, err := fs.Link(c, reqPath, model.LinkArgs{IP: c.ClientIP(), Header: c.Request.Header})