作者 tangxvhui

新增视频上传保存

@@ -78,3 +78,27 @@ func saveFile(fileData *multipart.FileHeader, fileType string) (hostpath string, @@ -78,3 +78,27 @@ func saveFile(fileData *multipart.FileHeader, fileType string) (hostpath string,
78 hostpath = config.MConfig.FileHost + filepath.Join(config.MConfig.FileHostPath, fileType, mfileName) 78 hostpath = config.MConfig.FileHost + filepath.Join(config.MConfig.FileHostPath, fileType, mfileName)
79 return hostpath, nil 79 return hostpath, nil
80 } 80 }
  81 +
  82 +//UploadVideo 视频上传
  83 +//@router /video
  84 +func (c *UploadController) UploadVideo() {
  85 + var msg *protocol.ResponseMessage
  86 + defer func() {
  87 + c.ResposeJson(msg)
  88 + }()
  89 + filehead, err := c.GetFiles("file")
  90 + if err != nil {
  91 + log.Error("获取上传文件失败:%s", err)
  92 + }
  93 + var rsp ResponseUploadImage
  94 + for i := range filehead {
  95 + hostpath, err := saveFile(filehead[i], "video")
  96 + if err != nil {
  97 + msg = protocol.BadRequestParam("1")
  98 + return
  99 + }
  100 + rsp.Urls = append(rsp.Urls, hostpath)
  101 + }
  102 + msg = protocol.NewReturnResponse(rsp, nil)
  103 + return
  104 +}
@@ -94,6 +94,7 @@ func init() { @@ -94,6 +94,7 @@ func init() {
94 ), 94 ),
95 beego.NSNamespace("/upload", 95 beego.NSNamespace("/upload",
96 beego.NSRouter("/image", &controllers.UploadController{}, "post:UploadImage"), 96 beego.NSRouter("/image", &controllers.UploadController{}, "post:UploadImage"),
  97 + beego.NSRouter("/video", &controllers.UploadController{}, "post:UploadVideo"),
97 ), 98 ),
98 99
99 beego.NSNamespace("/config", 100 beego.NSNamespace("/config",