/// <summary> /// Creates and returns an Cloud Storage client /// </summary> /// <param name="endpoint">Location of the server, supports HTTP and HTTPS</param> /// <param name="accessKey">Access Key for authenticated requests (Optional, can be omitted for anonymous requests)</param> /// <param name="secretKey">Secret Key for authenticated requests (Optional, can be omitted for anonymous requests)</param> /// <param name="region">Optional custom region</param> /// <param name="sessionToken">Optional session token</param> /// <returns>Client initialized with user credentials</returns> public MinioClient(string endpoint, string accessKey = "", string secretKey = "", string region = "", string sessionToken = "") { this.Secure = false; // Save user entered credentials this.BaseUrl = endpoint; this.AccessKey = accessKey; this.SecretKey = secretKey; this.SessionToken = sessionToken; this.Region = region; // Instantiate a region cache this.regionCache = BucketRegionCache.Instance; if (string.IsNullOrEmpty(this.BaseUrl)) { throw new InvalidEndpointException("Endpoint cannot be empty."); } string host = this.BaseUrl; var scheme = this.Secure ? utils.UrlEncode("https") : utils.UrlEncode("http"); // This is the actual url pointed to for all HTTP requests this.Endpoint = string.Format("{0}://{1}", scheme, host); this.uri = RequestUtil.GetEndpointURL(this.BaseUrl, this.Secure); RequestUtil.ValidateEndpoint(this.uri, this.Endpoint); this.HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", this.FullUserAgent); }
/// <summary> /// Creates and returns an Cloud Storage client /// </summary> /// <param name="endpoint">Location of the server, supports HTTP and HTTPS</param> /// <param name="accessKey">Access Key for authenticated requests (Optional,can be omitted for anonymous requests)</param> /// <param name="secretKey">Secret Key for authenticated requests (Optional,can be omitted for anonymous requests)</param> /// <param name="region">Optional custom region</param> /// <returns>Client initialized with user credentials</returns> public MinioClient(string endpoint, string accessKey = "", string secretKey = "", string region = "") { this.Secure = false; // Save user entered credentials this.BaseUrl = endpoint; this.AccessKey = accessKey; this.SecretKey = secretKey; this.Region = region; // Instantiate a region cache this.regionCache = BucketRegionCache.Instance; initClient(); }
/// <summary> /// Creates and returns an Cloud Storage client /// </summary> /// <param name="config">Configuration overrides</param> /// <returns>Client initialized with user credentials</returns> public MinioClient(MinioClientConfig config) { this.Secure = config.Secure; // Save user entered credentials this.BaseUrl = config.Endpoint; this.AccessKey = config.AccessKey; this.SecretKey = config.SecretKey; this.SessionToken = config.SessionToken; this.Region = config.Region; this.defaultServerTransferPartSize = config.DefaultServerTransferPartSize; // Instantiate a region cache this.regionCache = BucketRegionCache.Instance; this.Advanced = new MinioClientAdvanced(this); this.InitClient(); }