Exemplo n.º 1
0
        /// <summary>
        /// 清空标签
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public OperateResultDto ClearTag(ClearTagBucketParam request)
        {
            new ClearTagBucketParamValidator().Validate(request).Check(HttpStatus.Err.Name);
            var         scheme      = Core.Tools.GetScheme(_qiNiuConfig, request.PersistentOps.IsUseHttps);
            string      bucket      = Core.Tools.GetBucket(_qiNiuConfig, request.PersistentOps.Bucket);
            RestClient  restClient  = new RestClient($"{scheme}uc.qbox.me");
            RestRequest restRequest = new RestRequest($"/bucketTagging?bucket={bucket}", Method.DELETE);

            GetManageTokenParam param =
                new GetManageTokenParam($"{scheme}uc.qbox.me/bucketTagging?bucket={bucket}");

            restRequest.AddHeader("Authorization",
                                  $"{_storageProvider.GetManageToken(param)}");
            restRequest.AddParameter("application/json; charset=utf-8;", _jsonProvider.Serializer(new { }),
                                     ParameterType.RequestBody);
            try
            {
                string response = restClient.Execute(restRequest).Content;
                return(GetResponse(response, () => new OperateResultDto(true,
                                                                        "success"),
                                   resultResponse =>
                                   new OperateResultDto(false, $"{resultResponse.Error}|{resultResponse.ErrorCode}")));
            }
            catch (Exception ex)
            {
                this._logger?.LogError(ex.ExtractAllStackTrace());
                return(new OperateResultDto(false, $"lose {ex.Message}"));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到管理凭证
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public string GetManageToken(GetManageTokenParam request)
        {
            ICredentialsProvider provider = (ICredentialsProvider) new DefaultCredentialsProvider(
                (ICredentials) new DefaultCredentials(_aLiYunConfig.AccessKey,
                                                      _aLiYunConfig.SecretKey, (string)null));

            return(provider.GetCredentials().SecurityToken);
        }
 /// <summary>
 /// 得到管理凭证
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public string GetManageToken(GetManageTokenParam request)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// 得到管理凭证
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public string GetManageToken(GetManageTokenParam request)
 {
     new GetManageTokenParamValidator().Validate(request).Check(HttpStatus.Err.Name);
     return(GetAuth().CreateManageToken(request.Url));
 }