附近小店
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

58 rindas
1.5 KiB

  1. package hdl
  2. import (
  3. "applet/app/utils"
  4. "fmt"
  5. "github.com/gin-gonic/gin"
  6. "applet/app/e"
  7. "applet/app/md"
  8. "applet/app/svc"
  9. )
  10. // 文件七牛云回调确认
  11. func FileImgCallback(c *gin.Context) {
  12. masterID := c.Query("master_id")
  13. c.Set("mid", masterID)
  14. var args md.FileCallback
  15. err := c.ShouldBindJSON(&args)
  16. utils.FilePutContents("qiniuyun", masterID)
  17. if err != nil {
  18. utils.FilePutContents("qiniuyun", utils.SerializeStr(err))
  19. fmt.Println("七牛云上传回调参数错误:>>>>>>>>>>", err)
  20. e.OutErr(c, 200, e.ERR_INVALID_ARGS)
  21. return
  22. }
  23. fmt.Println("七牛云上传回调参数:>>>>>>>>>>", utils.SerializeStr(args))
  24. if err = svc.FileSave(c, &args); err != nil {
  25. utils.FilePutContents("qiniuyun", utils.SerializeStr(err))
  26. fmt.Println("七牛云上传回调保存文件错误:>>>>>>>>>>", err)
  27. e.OutErr(c, 200, err)
  28. return
  29. }
  30. res := map[string]interface{}{
  31. "name": args.FileName,
  32. "fname": getFileNameURL(c, args.FileName),
  33. "fsize": args.FileSize,
  34. "provider": args.Provider,
  35. "uid": args.Uid,
  36. "dir_id": args.DirId,
  37. "w": args.Width,
  38. "h": args.Height,
  39. }
  40. e.OutSuc(c, &res, nil)
  41. }
  42. func getFileNameURL(c *gin.Context, filename string) string {
  43. protocol := svc.SysCfgGet(c, "file_bucket_scheme")
  44. domain := svc.SysCfgGet(c, "file_bucket_host")
  45. imgformat := svc.SysCfgGet(c, "file_avatar_thumbnail")
  46. if protocol != "" && domain != "" && imgformat != "" {
  47. return protocol + "://" + domain + "/" + filename
  48. }
  49. return filename
  50. }