Inheritance: Qiniu.Http.HttpResult
Example #1
0
 public BucketsResult buckets()
 {
     BucketsResult bucketsResult = null;
     List<string> buckets = new List<string>();
     string url = string.Format("{0}/buckets", Config.RS_HOST);
     string token = Auth.createManageToken(url, null, this.mac);
     HttpManager httpManager = new HttpManager();
     httpManager.setAuthHeader(token);
     httpManager.CompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
     {
         bucketsResult = new BucketsResult();
         bucketsResult.Response = response;
         bucketsResult.ResponseInfo = respInfo;
         if (respInfo.isOk())
         {
             buckets = JsonConvert.DeserializeObject<List<string>>(response);
             bucketsResult.Buckets = buckets;
         }
     });
     httpManager.post(url);
     return bucketsResult;
 }
Example #2
0
        public BucketsResult buckets()
        {
            BucketsResult bucketsResult = null;
            List<string> buckets = new List<string>();
            string bucketsUrl = string.Format("{0}/buckets", Config.ZONE.RsHost);
            string accessToken = Auth.createManageToken(bucketsUrl, null, this.mac);
            Dictionary<string, string> bucketsHeaders = new Dictionary<string, string>();
            bucketsHeaders.Add("Authorization", accessToken);
            CompletionHandler bucketsCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response)
            {
                bucketsResult = new BucketsResult();
                bucketsResult.Response = response;
                bucketsResult.ResponseInfo = respInfo;
                if (respInfo.isOk())
                {
                    buckets = JsonConvert.DeserializeObject<List<string>>(response);
                    bucketsResult.Buckets = buckets;
                }
            });

            this.mHttpManager.get(bucketsUrl, bucketsHeaders, bucketsCompletionHandler);
            return bucketsResult;
        }