service/vendor/app/mix/controller/media.go

44 lines
1012 B
Go

package controller
import (
"service/api/errcode"
mediaproto "service/api/proto/media/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
// 获取签名
func MediaAuth(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*mediaproto.MediaAuthReq)
policyToken, ec := service.DefaultService.MediaAuth(ctx, req)
if ec != errcode.ErrCodeMediaSrvOk {
logger.Error("OpUpdateProduct fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &mediaproto.MediaAuthData{
PolicyToken: policyToken,
}
ReplyOk(ctx, data)
}
// 上传媒体
func CUpload(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*mediaproto.CUploadReq)
ret, ec := service.DefaultService.CUpload(ctx, req)
if ec != errcode.ErrCodeMediaSrvOk {
logger.Error("CUpload fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &mediaproto.CUploadData{
RetItem: ret,
}
ReplyOk(ctx, data)
}