internal static ZoneID GetZone(IQiniuSerializer serializer, string accessKey, string bucket) { if (serializer == null) { throw new ArgumentNullException("请添加 JSON 序列化组件"); } var zoneID = ZoneID.Invalid; try { var url = "https://uc.qbox.me/v1/query?ak=" + accessKey + "&bucket=" + bucket; var result = new HttpManager().Get(url, null); if (result.Code != (int)HttpCode.OK) { throw new Exception("code: " + result.Code + ", text: " + result.Text + ", ref-text:" + result.RefText); } var info = serializer.Deserialize <ZoneInfo>(result.Text); if (info == null) { throw new Exception("JSON Deserialize failed: " + result.Text); } zoneID = _ZONE_DICT[info.HTTP.UP[0]]; } catch (Exception exception) { var builder = new StringBuilder(); builder.AppendFormat("[{0:yyyy-MM-dd HH:mm:ss.ffff}] QueryZone Error:", DateTime.Now); var tempEx = exception; while (tempEx != null) { builder.AppendFormat(" {0}", tempEx.Message); tempEx = tempEx.InnerException; } builder.AppendLine(); throw new Exception(builder.ToString()); } return(zoneID); }
internal Signature(IQiniuSerializer serializer, string accessKey, string secretKey) { _accessKey = accessKey; _secretKey = secretKey; _serializer = serializer; }