public HttpResult batch(string ops) { HttpResult batchResult = null; string batchUrl = string.Format("{0}{1}", Config.ZONE.RsHost, "/batch"); string accessToken = Auth.createManageToken(batchUrl, Encoding.UTF8.GetBytes(ops), this.mac); Dictionary <string, string> batchHeaders = new Dictionary <string, string>(); batchHeaders.Add("Authorization", accessToken); CompletionHandler batchCompletionHandler = new CompletionHandler(delegate(ResponseInfo respInfo, string response) { batchResult = new FetchResult(); batchResult.Response = response; batchResult.ResponseInfo = respInfo; }); this.mHttpManager.postData(batchUrl, batchHeaders, Encoding.UTF8.GetBytes(ops), HttpManager.FORM_MIME_URLENCODED, batchCompletionHandler); return(batchResult); }
/// <summary> /// 抓取文件 /// </summary> /// <param name="resUrl">资源URL</param> /// <param name="bucket">空间名称</param> /// <param name="key">文件key</param> /// <returns>状态码为200时表示OK</returns> public async Task <FetchResult> Fetch(string resUrl, string bucket, string key) { var result = new FetchResult(); try { var host = await _config.IovipHost(_mac.AccessKey, bucket); var fetchUrl = $"{host}{FetchOp(resUrl, bucket, key)}"; var token = _auth.CreateManageToken(fetchUrl); var httpResult = await _httpManager.PostAsync(fetchUrl, token); result.Shadow(httpResult); } catch (QiniuException ex) { var sb = new StringBuilder(); sb.Append($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.ffff}] [fetch] Error: "); Exception e = ex; while (e != null) { sb.Append(e.Message + " "); e = e.InnerException; } sb.AppendLine(); result.Code = ex.HttpResult.Code; result.RefCode = ex.HttpResult.Code; result.Text = ex.HttpResult.Text; result.RefText += sb.ToString(); } return(result); }