作者 yangfu

上传

... ... @@ -20,9 +20,9 @@ yunpian_sms_sdk_url ="https://sms.yunpian.com/v2/sms/single_send.json"
yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5"
#存储 http://ability.fjmaimaimai.com:8080/
source_host ="http://192.168.139.131:8080/"
source_host ="http://192.168.139.137:8080/"
source_virtual_path=file/opp
source_path =/www/opp
source_path =~/www/opp
#网易云信 IM
net_im_base_url ="https://api.netease.im/nimserver"
... ...
... ... @@ -103,7 +103,7 @@ func FilterComm(ctx *context.Context) {
//统计
MetricCounter(ctx)
if beego.BConfig.RunMode == "dev" {
if beego.BConfig.RunMode == "dev" && (ctx.Input.Header("x-mmm-uid")!="" || ctx.Input.Header("uid")!=""){
return
}
//1.检查签名
... ...
... ... @@ -39,7 +39,7 @@ func (this *UploadController) Image() {
msg = protocol.NewReturnResponse(upload.Image(request))
}
// Image
// Voice
// @router /voice [post]
func (this *UploadController) Voice() {
var (
... ... @@ -65,3 +65,21 @@ func (this *UploadController) Voice() {
}
msg = protocol.NewReturnResponse(upload.Voice(request))
}
// Video
// @router /video [post]
func (this *UploadController) Video() {
var (
msg *protocol.ResponseMessage
err error
)
defer func() {
this.Resp(msg)
}()
var request = &protocol.FileRequest{}
if request.Files, err = this.GetFiles("file"); err != nil {
log.Error(err)
return
}
msg = protocol.NewReturnResponse(upload.Video(request))
}
... ...
... ... @@ -5,6 +5,7 @@ import "mime/multipart"
const (
FileImage = "image"
FileVoice = "voice"
FileVideo ="video"
)
/*Image */
... ...
... ... @@ -161,6 +161,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Video",
Router: `/video`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Voice",
Router: `/voice`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -21,7 +21,7 @@ func init() {
beego.NSNamespace("message", beego.NSInclude(&v1.MessageController{})),
)
beego.AddNamespace(nsV1)
beego.SetStaticPath("/file/ab", beego.AppConfig.String("source_path"))
beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path"))
beego.Handler("/metrics", promhttp.Handler())
beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage))
}
... ...
... ... @@ -39,6 +39,12 @@ func Voice(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error
return UploadFile(request)
}
func Video(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error) {
var ()
request.FileType = protocol.FileVideo
return UploadFile(request)
}
func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err error) {
if request.FileType == "" {
request.FileType = protocol.FileImage
... ...