...
|
...
|
@@ -41,12 +41,8 @@ func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Clie |
|
|
//获取视频上传地址和凭证,并创建视频信息
|
|
|
func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (response *CreateUploadVideoResponse, err error) {
|
|
|
request := vod.CreateCreateUploadVideoRequest()
|
|
|
filePath := getFileName(FileVideo, r.FileName)
|
|
|
if filepath.Ext(r.FileName) == "mp3" {
|
|
|
filePath = getFileName(FileVoice, r.FileName)
|
|
|
}
|
|
|
request.Title = filePath
|
|
|
request.FileName = filePath
|
|
|
request.Title = r.Title
|
|
|
request.FileName = r.FileName
|
|
|
request.AcceptFormat = "JSON"
|
|
|
rsp, err := client.CreateUploadVideo(request)
|
|
|
if err != nil {
|
...
|
...
|
@@ -58,11 +54,6 @@ func CreateUploadVideo(client *vod.Client, r *CreateUploadVideoRequest) (respons |
|
|
UploadAddress: rsp.UploadAddress,
|
|
|
UploadAuth: rsp.UploadAuth,
|
|
|
}
|
|
|
if up, e := ParseUploadAddress(rsp.UploadAddress); e != nil {
|
|
|
log.Error(e)
|
|
|
} else {
|
|
|
response.FileURL = up.GetFileUrl(beego.AppConfig.String("cname"))
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -90,9 +81,8 @@ func RefreshUploadVideo(client *vod.Client, r *RefreshUploadVideoRequest) (respo |
|
|
//获取图片上传地址和凭证,并创建视频信息
|
|
|
func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (response *CreateUploadImageResponse, err error) {
|
|
|
request := vod.CreateCreateUploadImageRequest()
|
|
|
filePath := getFileName(FileImage, r.FileName)
|
|
|
request.ImageType = "default"
|
|
|
request.Title = filePath
|
|
|
request.Title = r.Title
|
|
|
request.ImageExt = filepath.Ext(r.FileName)[1:]
|
|
|
request.AcceptFormat = "JSON"
|
|
|
//request.StorageLocation = filepath.Base(request.Title)
|
...
|
...
|
@@ -127,7 +117,7 @@ func GetGetVideoPlayAuth(client *vod.Client, r *GetVideoPlayAuthRequest) (respon |
|
|
}
|
|
|
|
|
|
//fileType: video voice image
|
|
|
func getFileName(fileType string, filename string) string {
|
|
|
func GetFileName(fileType string, filename string) string {
|
|
|
date := comm_time.GetTimeByYyyymmdd()
|
|
|
subfix := path.Ext(filename)
|
|
|
prefix := fmt.Sprintf("%v_%v", time.Now().Unix(), common.RandomString(32))
|
...
|
...
|
|