作者 yangfu

视频点播修改

... ... @@ -30,6 +30,9 @@ func (this *VodController) CreateUploadVideo() {
msg = m
return
}
if len(request.FileName) == 0 {
request.FileName = aliyun.DefaultVideoFileName
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.CreateUploadVideo(header, request))
}
... ...
... ... @@ -13,3 +13,9 @@ const (
FileVoice = "voice"
FileVideo = "video"
)
const (
DefaultVideoFileName = "test.mp4"
DefaultVoiceFileName = "test.mp3"
DefaultImageFileName = "test.jpg"
)
... ...
package aliyun
import (
"github.com/astaxie/beego"
)
/*
AK AccessKey 完全访问权限
STS (Security Token Service) 临时访问控制
*/
var (
Endpoint string = beego.AppConfig.String("end_point")
BucketName string = beego.AppConfig.String("bucket_name")
//BucketNameCdn string = beego.AppConfig.String("bucket_name_cdn")
//EndpointCdn string = beego.AppConfig.String("end_point_cdn")
)
//type OssSts struct{
//
//}
//func NewSTS(){
// client,_ :=oos.NewClientWithAccessKey(RegionID,AccessKeyID,AccessKeySecret)
// client.DoAction()
//}
... ...
... ... @@ -3,6 +3,7 @@ package aliyun
//创建视频上传凭证
/*CreateUploadVideo */
type CreateUploadVideoRequest struct {
FileName string `position:"Query" name:"fileName"`
}
type CreateUploadVideoResponse struct {
... ...
package aliyun
type CreateUploadImageRequest struct {
FileName string `json:"fileName"`
}
type CreateUploadImageResponse struct {
... ...
... ... @@ -10,6 +10,7 @@ import (
comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
"opp/internal/utils"
"path"
"path/filepath"
"time"
)
... ... @@ -39,10 +40,13 @@ func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Clie
//获取视频上传地址和凭证,并创建视频信息
func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (response *CreateUploadVideoResponse, err error) {
request := vod.CreateCreateUploadVideoRequest()
request.Title = getFileName(FileVideo, "video_file.mp4")
request.FileName = getFileName(FileVideo, "video_file.mp4")
//request.CoverURL = "http://img.alicdn.com/tps/TB1qnJ1PVXXXXXCXXXXXXXXXXXX-700-700.png"
//request.Tags = "tag1,tag2"
filePath := getFileName(FileVideo, r.FileName)
if filepath.Ext(r.FileName) == "mp3" {
filePath = getFileName(FileVideo, r.FileName)
}
request.Title = filePath
request.FileName = filePath
//request.StorageLocation = filepath.Base(filePath)
request.AcceptFormat = "JSON"
rsp, err := client.CreateUploadVideo(request)
if err != nil {
... ... @@ -60,9 +64,12 @@ func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (respons
//获取图片上传地址和凭证,并创建视频信息
func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (response *CreateUploadImageResponse, err error) {
request := vod.CreateCreateUploadImageRequest()
request.ImageType = "cover"
filePath := getFileName(FileImage, r.FileName)
request.ImageType = "default"
request.Title = filePath
request.ImageExt = filepath.Ext(r.FileName)
request.AcceptFormat = "JSON"
request.ImageExt = "jpg"
//request.StorageLocation = filepath.Base(request.Title)
rsp, err := client.CreateUploadImage(request)
if err != nil {
return
... ...
... ... @@ -145,6 +145,9 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl
return
}
rsp, err = aliyun.CreateUploadVideo(client, request)
if err != nil {
log.Error(err)
}
return
}
... ...