|
@@ -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
|
+} |