///上传视频到七牛并转码///
///
///
public static void UpLoadVideo(string saveKey, stringlocalFile)
{
Mac mac= newMac(ACCESS_KEY, SECRET_KEY);
PutPolicy putPolicy= newPutPolicy();//如果需要设置为"覆盖"上传(如果云端已有同名文件则覆盖),请使用 SCOPE = "BUCKET:KEY"//putPolicy.Scope = bucket + ":" + saveKey;
putPolicy.Scope =bucket;//上传策略有效期(对应于生成的凭证的有效期)
putPolicy.SetExpires(3600);
putPolicy.PersistentPipeline= "UpLoadVideo";//进行视屏转码 (转成 mp4 资源和对原资源进行 HLS 切片)
putPolicy.PersistentOps = "avthumb/mp4;avthumb/m3u8/noDomain/1/segtime/15/vb/440k";//上传到云端多少天后自动删除该文件,如果不设置(即保持默认默认)则不删除//putPolicy.DeleteAfterDays = 1;//生成上传凭证,参见// https://developer.qiniu.com/kodo/manual/upload-token
//string jstr = putPolicy.ToJsonString();
string token =Auth.createUploadToken(putPolicy, mac);
UploadOptions uploadOptions= null;//上传完毕事件处理
UpCompletionHandler uploadCompleted = newUpCompletionHandler(OnUploadCompleted);//方式1:使用UploadManager//默认设置 Qiniu.Common.Config.PUT_THRESHOLD = 512*1024;//可以适当修改,UploadManager会根据这个阈值自动选择是否使用分片(Resumable)上传
收起