feat: file proxy handle

This commit is contained in:
Noah Hsu
2022-06-28 21:58:46 +08:00
parent d1efec4539
commit 96380a50da
11 changed files with 167 additions and 90 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/alist-org/alist/v3/internal/fs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/setting"
"github.com/alist-org/alist/v3/internal/sign"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/alist-org/alist/v3/server/common"
"github.com/gin-gonic/gin"
@ -108,20 +107,8 @@ func toObjResp(objs []model.Obj, path string, baseURL string) []ObjResp {
Size: obj.GetSize(),
IsDir: obj.IsDir(),
Modified: obj.ModTime(),
Sign: Sign(obj),
Sign: common.Sign(obj),
})
}
return resp
}
func Sign(obj model.Obj) string {
if obj.IsDir() {
return ""
}
expire := setting.GetIntSetting("link_expiration", 0)
if expire == 0 {
return sign.NotExpired(obj.GetName())
} else {
return sign.WithDuration(obj.GetName(), time.Duration(expire)*time.Hour)
}
}