|
123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package hdl
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/utils"
- "fmt"
- "github.com/gin-gonic/gin"
- )
-
- func FileImgCallback(c *gin.Context) {
- var args md.FileCallback
- if err := c.ShouldBindJSON(&args); err != nil {
- e.OutErr(c, 200, e.ERR_INVALID_ARGS)
- return
- }
- fmt.Println("callback args:", utils.SerializeStr(args))
-
- res := map[string]interface{}{
- "name": args.FileName,
- "fname": getFileNameURL(c, args.FileName),
- "fsize": args.FileSize,
- "provider": args.Provider,
- "uid": args.Uid,
- "dir_id": args.DirId,
- "w": args.Width,
- "h": args.Height,
- }
- fmt.Println("callback res:", utils.SerializeStr(res))
-
- e.OutSuc(c, &res, nil)
-
- }
-
- func getFileNameURL(c *gin.Context, filename string) string {
- masterListCfgDb := db.MasterListCfgDb{}
- masterListCfgDb.Set()
- protocol := masterListCfgDb.MasterListCfgGetOneData("0", "file_bucket_scheme")
- domain := masterListCfgDb.MasterListCfgGetOneData("0", "file_bucket_host")
- if protocol != "" && domain != "" {
- return protocol + "://" + domain + "/" + filename
- }
- return filename
- }
|