作者 yangfu

上传

@@ -20,9 +20,9 @@ yunpian_sms_sdk_url ="https://sms.yunpian.com/v2/sms/single_send.json" @@ -20,9 +20,9 @@ yunpian_sms_sdk_url ="https://sms.yunpian.com/v2/sms/single_send.json"
20 yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" 20 yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5"
21 21
22 #存储 http://ability.fjmaimaimai.com:8080/ 22 #存储 http://ability.fjmaimaimai.com:8080/
23 -source_host ="http://192.168.139.131:8080/" 23 +source_host ="http://192.168.139.137:8080/"
24 source_virtual_path=file/opp 24 source_virtual_path=file/opp
25 -source_path =/www/opp 25 +source_path =~/www/opp
26 26
27 #网易云信 IM 27 #网易云信 IM
28 net_im_base_url ="https://api.netease.im/nimserver" 28 net_im_base_url ="https://api.netease.im/nimserver"
@@ -103,7 +103,7 @@ func FilterComm(ctx *context.Context) { @@ -103,7 +103,7 @@ func FilterComm(ctx *context.Context) {
103 //统计 103 //统计
104 MetricCounter(ctx) 104 MetricCounter(ctx)
105 105
106 - if beego.BConfig.RunMode == "dev" { 106 + if beego.BConfig.RunMode == "dev" && (ctx.Input.Header("x-mmm-uid")!="" || ctx.Input.Header("uid")!=""){
107 return 107 return
108 } 108 }
109 //1.检查签名 109 //1.检查签名
@@ -39,7 +39,7 @@ func (this *UploadController) Image() { @@ -39,7 +39,7 @@ func (this *UploadController) Image() {
39 msg = protocol.NewReturnResponse(upload.Image(request)) 39 msg = protocol.NewReturnResponse(upload.Image(request))
40 } 40 }
41 41
42 -// Image 42 +// Voice
43 // @router /voice [post] 43 // @router /voice [post]
44 func (this *UploadController) Voice() { 44 func (this *UploadController) Voice() {
45 var ( 45 var (
@@ -65,3 +65,21 @@ func (this *UploadController) Voice() { @@ -65,3 +65,21 @@ func (this *UploadController) Voice() {
65 } 65 }
66 msg = protocol.NewReturnResponse(upload.Voice(request)) 66 msg = protocol.NewReturnResponse(upload.Voice(request))
67 } 67 }
  68 +
  69 +// Video
  70 +// @router /video [post]
  71 +func (this *UploadController) Video() {
  72 + var (
  73 + msg *protocol.ResponseMessage
  74 + err error
  75 + )
  76 + defer func() {
  77 + this.Resp(msg)
  78 + }()
  79 + var request = &protocol.FileRequest{}
  80 + if request.Files, err = this.GetFiles("file"); err != nil {
  81 + log.Error(err)
  82 + return
  83 + }
  84 + msg = protocol.NewReturnResponse(upload.Video(request))
  85 +}
@@ -5,6 +5,7 @@ import "mime/multipart" @@ -5,6 +5,7 @@ import "mime/multipart"
5 const ( 5 const (
6 FileImage = "image" 6 FileImage = "image"
7 FileVoice = "voice" 7 FileVoice = "voice"
  8 + FileVideo ="video"
8 ) 9 )
9 10
10 /*Image */ 11 /*Image */
@@ -161,6 +161,14 @@ func init() { @@ -161,6 +161,14 @@ func init() {
161 161
162 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 162 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
163 beego.ControllerComments{ 163 beego.ControllerComments{
  164 + Method: "Video",
  165 + Router: `/video`,
  166 + AllowHTTPMethods: []string{"post"},
  167 + MethodParams: param.Make(),
  168 + Params: nil})
  169 +
  170 + beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
  171 + beego.ControllerComments{
164 Method: "Voice", 172 Method: "Voice",
165 Router: `/voice`, 173 Router: `/voice`,
166 AllowHTTPMethods: []string{"post"}, 174 AllowHTTPMethods: []string{"post"},
@@ -21,7 +21,7 @@ func init() { @@ -21,7 +21,7 @@ func init() {
21 beego.NSNamespace("message", beego.NSInclude(&v1.MessageController{})), 21 beego.NSNamespace("message", beego.NSInclude(&v1.MessageController{})),
22 ) 22 )
23 beego.AddNamespace(nsV1) 23 beego.AddNamespace(nsV1)
24 - beego.SetStaticPath("/file/ab", beego.AppConfig.String("source_path")) 24 + beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path"))
25 beego.Handler("/metrics", promhttp.Handler()) 25 beego.Handler("/metrics", promhttp.Handler())
26 beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage)) 26 beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage))
27 } 27 }
@@ -39,6 +39,12 @@ func Voice(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error @@ -39,6 +39,12 @@ func Voice(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error
39 return UploadFile(request) 39 return UploadFile(request)
40 } 40 }
41 41
  42 +func Video(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error) {
  43 + var ()
  44 + request.FileType = protocol.FileVideo
  45 + return UploadFile(request)
  46 +}
  47 +
42 func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error) { 48 func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error) {
43 if request.FileType == "" { 49 if request.FileType == "" {
44 request.FileType = protocol.FileImage 50 request.FileType = protocol.FileImage