Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-12-21 18:42:32 +08:00
parent 6588af2f32
commit 1c48345150
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 42 additions and 0 deletions

View file

@ -406,6 +406,38 @@ func uploadCloud(c *gin.Context) {
util.PushMsg(fmt.Sprintf(model.Conf.Language(41), count), 3000)
}
func uploadCloudByAssetsPaths(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
if nil == arg["paths"] {
ret.Code = -1
ret.Msg = "paths is required"
return
}
pathsArg := arg["paths"].([]interface{})
var assets []string
for _, pathArg := range pathsArg {
assets = append(assets, pathArg.(string))
}
count, err := model.UploadAssets2CloudByAssetsPaths(assets)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
ret.Data = map[string]interface{}{"closeTimeout": 3000}
return
}
util.PushMsg(fmt.Sprintf(model.Conf.Language(41), count), 3000)
}
func insertLocalAssets(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -291,6 +291,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/clipboard/readFilePaths", model.CheckAuth, model.CheckAdminRole, readFilePaths)
ginServer.Handle("POST", "/api/asset/uploadCloud", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, uploadCloud)
ginServer.Handle("POST", "/api/asset/uploadCloudByAssetsPaths", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, uploadCloudByAssetsPaths)
ginServer.Handle("POST", "/api/asset/insertLocalAssets", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, insertLocalAssets)
ginServer.Handle("POST", "/api/asset/resolveAssetPath", model.CheckAuth, resolveAssetPath)
ginServer.Handle("POST", "/api/asset/upload", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, model.Upload)

View file

@ -516,6 +516,15 @@ func UploadAssets2Cloud(id string) (count int, err error) {
return
}
func UploadAssets2CloudByAssetsPaths(assetPaths []string) (count int, err error) {
if !IsSubscriber() {
return
}
count, err = uploadAssets2Cloud(assetPaths, bizTypeUploadAssets)
return
}
const (
bizTypeUploadAssets = "upload-assets"
bizTypeExport2Liandi = "export-liandi"