mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
6588af2f32
commit
1c48345150
3 changed files with 42 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue