/// <summary> /// 创建上传token /// </summary> /// <returns></returns> private string CreateUploadToken() { // 上传策略 var putPolicy = new PutPolicy(); // 设置要上传的目标空间 putPolicy.Scope = this.Bucket; putPolicy.SetExpires(3600); var mac = new Mac(this.AK, this.SK); // 生成上传凭证 var uploadToken = new Qiniu.Util.Auth(mac).CreateUploadToken(putPolicy.ToJsonString()); return(uploadToken); }
public static string CreateUploadToken(this Mac mac, string bucket) { // 上传策略 var putPolicy = new PutPolicy(); // 设置要上传的目标空间 putPolicy.Scope = bucket ?? throw new ArgumentNullException(nameof(bucket)); putPolicy.SetExpires(3600); // 生成上传凭证 var uploadToken = new Qiniu.Util.Auth(mac).CreateUploadToken(putPolicy.ToJsonString()); return(uploadToken); }