/// <summary> /// 构造函数。 /// </summary> /// <param name="accessKeyId">访问密钥中的AK</param> /// <param name="secretAccessKey">访问密钥中的SK</param> /// <param name="securityToken">安全令牌</param> /// <param name="endpoint">OBS的服务地址</param> public ObsClient(string accessKeyId, string secretAccessKey, string securityToken, string endpoint) { ObsConfig obsConfig = new ObsConfig() { Endpoint = endpoint }; this.init(accessKeyId, secretAccessKey, securityToken, obsConfig); }
internal void init(string accessKeyId, string secretAccessKey, string securityToken, ObsConfig obsConfig) { if (obsConfig == null || string.IsNullOrEmpty(obsConfig.Endpoint)) { throw new ObsException(Constants.InvalidEndpointMessage, ErrorType.Sender, Constants.InvalidEndpoint, ""); } SecurityProvider sp = new SecurityProvider(); sp.Ak = accessKeyId; sp.Sk = secretAccessKey; sp.Token = securityToken; this.sp = sp; this.ObsConfig = obsConfig; this.httpClient = new HttpClient(this.ObsConfig); if (this.ObsConfig.PathStyle) { this.ObsConfig.AuthTypeNegotiation = false; if (this.ObsConfig.AuthType == AuthTypeEnum.OBS) { this.ObsConfig.AuthType = AuthTypeEnum.V2; } } if (this.ObsConfig.AuthTypeNegotiation) { this.locksHolder = new LocksHolder(); authTypeCache = new AuthTypeCache(); } LoggerMgr.Initialize(); if (LoggerMgr.IsWarnEnabled) { StringBuilder sb = new StringBuilder(); sb.Append("[OBS SDK Version=") .Append(Constants.ObsSdkVersion) .Append("];[") .Append("Endpoint=") .Append(obsConfig.Endpoint) .Append("];[") .Append("Access Mode=") .Append(obsConfig.PathStyle ? "Path" : "Virtual Hosting") .Append("]"); LoggerMgr.Warn(sb.ToString()); } }
/// <summary> /// 构造函数。 /// </summary> /// <param name="accessKeyId">访问密钥中的AK</param> /// <param name="secretAccessKey">访问密钥中的SK</param> /// <param name="securityToken">安全令牌</param> /// <param name="obsConfig">OBS客户端配置参数</param> public ObsClient(string accessKeyId, string secretAccessKey, string securityToken, ObsConfig obsConfig) { this.init(accessKeyId, secretAccessKey, securityToken, obsConfig); }
/// <summary> /// 构造函数。 /// </summary> /// <param name="accessKeyId">访问密钥中的AK</param> /// <param name="secretAccessKey">访问密钥中的SK</param> /// <param name="obsConfig">OBS客户端配置参数</param> public ObsClient(string accessKeyId, string secretAccessKey, ObsConfig obsConfig) : this(accessKeyId, secretAccessKey, "", obsConfig) { }