web利用腾讯云点播上传视频

腾讯云web上传文件文档

https://cloud.tencent.com/document/product/266/9239#.E5.B8.B8.E8.A7.81.E9.97.AE.E9.A2.98

sdk:https://github.com/tencentyun/vod-js-sdk-v6

根据文档下载sdk或参考sdk即可

前端源代码地址 https://github.com/tencentyun/vod-js-sdk-v6/blob/master/docs/index.html

注意,前端获取签名的地址要改成自己后台的签名生成地址

web利用腾讯云点播上传视频_第1张图片

在视频上传成功里面加入自己的逻辑

 

 

c# 签名代码 

签名规范及参数文档 https://cloud.tencent.com/document/product/266/9221 

 /// 
    /// 获取web端上传视频签名   https://cloud.tencent.com/document/product/266/9219
    /// 
    /// 
    /// 
    private string TencentGetUploadSign(HttpContext context)
    {
        try
        {
            //调用方法
            Signature sign = new Signature();
            sign.m_strSecId = "AKIDkOODn9PJ2b2LWUQDxRl25xfVEk25qfLN";
            sign.m_strSecKey = "QSI5erqb7QUOK5KrEQ62lKfXGXayAC0b";
            sign.m_qwNowTime = Signature.GetIntTimeStamp();
            sign.m_iRandom = new Random().Next(0, 1000000);
            sign.m_iSignValidDuration = 3600 * 24 * 2;
            string signStr = sign.GetUploadSignature();
            //根据自己系统的规范返回
            return ReturnJson.AjaxJsonByDt(true, "", signStr);
        }
        catch (Exception ex)
        {
            LogHelper.WriteErrorLog(ex.ToString(), "APIError", "Live");
            return ReturnJson.AjaxJsonByDt(false, ex.Message, "");
        }
    }  





public class Signature
    {
        public string m_strSecId;
        public string m_strSecKey;
        public int m_iRandom;
        public long m_qwNowTime;
        public int m_iSignValidDuration;
        public static long GetIntTimeStamp()
        {
            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1);
            return Convert.ToInt64(ts.TotalSeconds);
        }
        private byte[] hash_hmac_byte(string signatureString, string secretKey)
        {
            var enc = Encoding.UTF8; HMACSHA1 hmac = new HMACSHA1(enc.GetBytes(secretKey));
            hmac.Initialize();
            byte[] buffer = enc.GetBytes(signatureString);
            return hmac.ComputeHash(buffer);
        }
        public string GetUploadSignature()
        {
            string strContent = "";
            strContent += ("secretId=" + Uri.EscapeDataString((m_strSecId)));
            strContent += ("¤tTimeStamp=" + m_qwNowTime);
            strContent += ("&expireTime=" + (m_qwNowTime + m_iSignValidDuration));
            strContent += ("&random=" + m_iRandom);
            byte[] bytesSign = hash_hmac_byte(strContent, m_strSecKey);
            byte[] byteContent = System.Text.Encoding.Default.GetBytes(strContent);
            byte[] nCon = new byte[bytesSign.Length + byteContent.Length];
            bytesSign.CopyTo(nCon, 0);
            byteContent.CopyTo(nCon, bytesSign.Length);
            return Convert.ToBase64String(nCon);
        }
    }

注意 :

添加签名其他参数时,其他参数要UrlEncode,  比如加转码时

procedure= HttpUtility.UrlEncode("转码任务流");

 

你可能感兴趣的:(直播视频相关API,#腾讯云)