/// <summary> /// 得到资源管理 /// </summary> /// <param name="persistentOps">策略</param> /// <returns></returns> protected virtual BucketManager GetBucketManager(BasePersistentOps persistentOps) { if (_bucketManager == null) { _bucketManager = new BucketManager(_qiNiuConfig.GetMac(), Core.Tools.GetConfig(_qiNiuConfig, persistentOps)); } return(_bucketManager); }
/// <summary> /// 得到资源管理 /// </summary> /// <returns></returns> protected BucketManager GetBucketManager() { if (_bucketManager == null) { _bucketManager = new BucketManager(_qiNiuConfig.GetMac(), GetConfig()); } return(_bucketManager); }
/// <summary> /// 得到上传凭证 /// </summary> /// <param name="qiNiuConfig">七牛配置文件</param> /// <param name="opsParam">上传策略</param> /// <param name="action"></param> /// <returns></returns> protected string GetUploadCredentials(QiNiuStorageConfig qiNiuConfig, UploadPersistentOpsParam opsParam, Action <PutPolicy> action = null) { PutPolicyConfig putPolicyConfig = new PutPolicyConfig(qiNiuConfig); putPolicyConfig.SetPutPolicy(opsParam); action?.Invoke(putPolicyConfig.GetPutPolicy()); return(Auth.CreateUploadToken(qiNiuConfig.GetMac(), putPolicyConfig.GetPutPolicy().ToJsonString())); }
/// <summary> /// /// </summary> /// <param name="context"></param> public void OnAuthorization(AuthorizationFilterContext context) { if (context.Filters.Any(item => item is IAllowAnonymousFilter)) { return; } string qiNiuAuthorization = context.HttpContext.Request.Headers["Authorization"]; if (string.IsNullOrEmpty(qiNiuAuthorization)) { AuthLose(context); return; } string callbackUrl = _qiNiuConfig.CallbackAuthHost + context.HttpContext.Request.Path.Value; string authorization = new Auth(_qiNiuConfig.GetMac()).CreateManageToken(callbackUrl); if (authorization != qiNiuAuthorization) { AuthLose(context); } }