//private readonly HttpClient _httpClient; public QiniuService(IOptions <QiniuOptions> options) // , IHttpClientFactory httpClientFactory { _options = options.Value; _mac = new Mac(_options.AccessKey, _options.SecretKey); _zone = ZoneHelper.QueryZone(_options.AccessKey, _options.Bucket); //_httpClient = httpClientFactory.CreateClient(); }
//reload buckets private void reloadBuckets() { //get new bucket list BucketsResult bucketsResult = this.bucketManager.Buckets(); if (bucketsResult.Code == (int)HttpCode.OK) { List <string> buckets = bucketsResult.Result; zoneDict.Clear(); foreach (string bucket in buckets) { ZoneID zoneId = ZoneHelper.QueryZone(SystemConfig.ACCESS_KEY, bucket); zoneDict.Add(bucket, zoneId); } Dispatcher.Invoke(new Action(delegate { this.SyncTargetBucketsComboBox.ItemsSource = buckets; })); } else { Log.Error("get buckets error, " + bucketsResult.Text); Dispatcher.Invoke(new Action(delegate { this.SettingsErrorTextBlock.Text = "获取空间列表时出错"; })); } }
/// <summary> /// 获取数据处理域名 /// </summary> /// <param name="ak"></param> /// <param name="bucket"></param> /// <returns></returns> public string ApiHost(string ak, string bucket) { string scheme = UseHttps ? "https://" : "http://"; Zone z = this.Zone; if (z == null) { z = ZoneHelper.QueryZone(ak, bucket); } return string.Format("{0}{1}", scheme, z.ApiHost); }
/// <summary> /// 获取资源管理域名 /// </summary> /// <param name="ak"></param> /// <param name="bucket"></param> /// <returns></returns> public string RsHost(string ak, string bucket) { string scheme = UseHttps ? "https://" : "http://"; Zone z = this.Zone; if (z == null) { z = ZoneHelper.QueryZone(ak, bucket); } return(string.Format("{0}{1}", scheme, z.ServerUploadDomain)); }
public static async Task <Zone> GetBucketZoneInfo(string bucketName) { return(await Task.Factory.StartNew(() => { #if MOCK return new Zone { ApiHost = Zone.ZONE_AS_Singapore.ApiHost }; #else return ZoneHelper.QueryZone(_currentMac.AccessKey, bucketName); #endif })); }
/// <summary> /// 获取文件上传域名 /// </summary> /// <param name="ak"></param> /// <param name="bucket"></param> /// <returns></returns> public string UpHost(string ak, string bucket) { string scheme = UseHttps ? "https://" : "http://"; Zone z = this.Zone; if (z == null) { z = ZoneHelper.QueryZone(ak, bucket); } string upHost = z.SrcUpHosts[0]; if (this.UseCdnDomains) { upHost = z.CdnUpHosts[0]; } return string.Format("{0}{1}", scheme, upHost); }
public void QueryZoneTest() { ZoneID zid = ZoneHelper.QueryZone(AccessKey, Bucket1); }