1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package utils
- import (
- "github.com/aliyun/aliyun-oss-go-sdk/oss"
- "lzyd-message-api/common"
- "os"
- "time"
- )
- func GetVideoSignedURL(strs string) string {
- // 创建OSSClient实例。
- client, err := oss.New(common.Endpoint, common.AccessKeyIdOSS, common.AccessSecretOss)
- if err != nil {
- os.Exit(-1)
- }
- // 获取存储空间。
- bucket, err := client.Bucket(common.BucketName)
- if err != nil {
- os.Exit(-1)
- }
- // 上传文件流。
- signedURL, err := bucket.SignURL(strs, oss.HTTPGet, 60*20)
- if err != nil {
- os.Exit(-1)
- }
- return signedURL
- }
- func GetSnapVideoSignedURL(strs string) string {
- // 创建OSSClient实例。
- client, err := oss.New(common.Endpoint, common.AccessKeyIdOSS, common.AccessSecretOss)
- if err != nil {
- os.Exit(-1)
- }
- // 获取存储空间。
- bucket, err := client.Bucket(common.BucketName)
- if err != nil {
- os.Exit(-1)
- }
- // 上传文件流。
- signedURL, err := bucket.SignURL(strs, oss.HTTPGet, 60*20, oss.AddParam("x-oss-process", "video/snapshot,t_7000,f_jpg,m_fast"))
- if err != nil {
- os.Exit(-1)
- }
- return signedURL
- }
- var expire_time int64 = 30
- var host string = "http://cloudsport-video.oss-cn-hangzhou.aliyuncs.com"
- type ConfigStruct struct {
- Expiration string `json:"expiration"`
- Conditions [][]string `json:"conditions"`
- }
- func get_gmt_iso8601(expire_end int64) string {
- var tokenExpire = time.Unix(expire_end, 0).Format("2006-01-02T15:04:05Z")
- return tokenExpire
- }
- type CallbackParam struct {
- CallbackUrl string `json:"callbackUrl"`
- CallbackBody string `json:"callbackBody"`
- CallbackBodyType string `json:"callbackBodyType"`
- }
- type PolicyToken struct {
- AccessKeyId string `json:"accessid"`
- Host string `json:"host"`
- Expire int64 `json:"expire"`
- Signature string `json:"signature"`
- Policy string `json:"policy"`
- Directory string `json:"dir"`
- Callback string `json:"callback"`
- }
|