internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("object-lock", ""); string body = utils.MarshalXML(new ObjectLockConfiguration(), "http://s3.amazonaws.com/doc/2006-03-01/"); requestMessageBuilder.AddXmlBody(body); requestMessageBuilder.AddOrUpdateHeaderParameter("Content-Md5", utils.getMD5SumStr(Encoding.UTF8.GetBytes(body))); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { foreach (var eventType in this.Events) { requestMessageBuilder.AddQueryParameter("events", eventType.value); } requestMessageBuilder.AddQueryParameter("prefix", this.Prefix); requestMessageBuilder.AddQueryParameter("suffix", this.Suffix); requestMessageBuilder.ResponseWriter = async responseStream => { using (responseStream) { var sr = new StreamReader(responseStream); while (!sr.EndOfStream) { try { string line = await sr.ReadLineAsync(); if (this.EnableTrace) { Console.WriteLine("== ListenBucketNotificationsAsync read line =="); Console.WriteLine(line); Console.WriteLine("=============================================="); } string trimmed = line.Trim(); if (trimmed.Length > 2) { this.NotificationObserver.OnNext(new MinioNotificationRaw(trimmed)); } } catch { break; } } } }; return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { if (string.IsNullOrEmpty(this.PolicyJsonString)) { new MinioException("SetPolicyArgs needs the policy to be set to the right JSON contents."); } requestMessageBuilder.AddQueryParameter("policy", ""); requestMessageBuilder.AddJsonBody(this.PolicyJsonString); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("replication", ""); string body = this.BucketReplication.MarshalXML(); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("tagging", ""); string body = this.BucketTags.MarshalXML(); requestMessageBuilder.AddXmlBody(body); requestMessageBuilder.AddOrUpdateHeaderParameter("Content-Md5", utils.getMD5SumStr(Encoding.UTF8.GetBytes(body))); // return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("notification", ""); BucketNotification bucketNotificationConfiguration = new BucketNotification(); string body = utils.MarshalXML(bucketNotificationConfiguration, "http://s3.amazonaws.com/doc/2006-03-01/"); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { VersioningConfiguration config = new VersioningConfiguration((this.CurrentVersioningStatus == VersioningStatus.Enabled)); string body = utils.MarshalXML(config, "http://s3.amazonaws.com/doc/2006-03-01/"); requestMessageBuilder.AddXmlBody(body); requestMessageBuilder.AddOrUpdateHeaderParameter("Content-Md5", utils.getMD5SumStr(Encoding.UTF8.GetBytes(body))); requestMessageBuilder.AddQueryParameter("versioning", ""); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("lifecycle", ""); string body = this.BucketLifecycle.MarshalXML(); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); requestMessageBuilder.AddOrUpdateHeaderParameter("Content-Md5", utils.getMD5SumStr(bodyInBytes)); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { if (this.EncryptionConfig == null) { this.EncryptionConfig = ServerSideEncryptionConfiguration.GetSSEConfigurationWithS3Rule(); } requestMessageBuilder.AddQueryParameter("encryption", ""); string body = utils.MarshalXML(this.EncryptionConfig, "http://s3.amazonaws.com/doc/2006-03-01/"); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { if (this.BucketNotificationConfiguration == null) { throw new UnexpectedMinioException("Cannot BuildRequest for SetBucketNotificationsArgs. BucketNotification configuration not assigned"); } requestMessageBuilder.AddQueryParameter("notification", ""); BucketNotification bucketNotificationConfiguration = new BucketNotification(); string body = utils.MarshalXML(bucketNotificationConfiguration, "http://s3.amazonaws.com/doc/2006-03-01/"); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); return(requestMessageBuilder); }
/// <summary> /// Updates Region cache for given bucket. /// </summary> /// <param name="client"></param> /// <param name="bucketName"></param> internal async Task <string> Update(MinioClient client, string bucketName) { string region = null; if (bucketName != null && client.AccessKey != null && client.SecretKey != null && !Instance.Exists(bucketName)) { string location = null; var path = utils.UrlEncode(bucketName); // Initialize client Uri requestUrl = RequestUtil.MakeTargetURL(client.BaseUrl, client.Secure); var requestBuilder = new HttpRequestMessageBuilder(HttpMethod.Get, requestUrl, path); requestBuilder.AddQueryParameter("location", ""); ResponseResult response = null; response = await client.ExecuteTaskAsync(client.NoErrorHandlers, requestBuilder).ConfigureAwait(false); if (response != null && HttpStatusCode.OK.Equals(response.StatusCode)) { XDocument root = XDocument.Parse(response.Content); location = root.Root.Value; } if (string.IsNullOrEmpty(location)) { region = "us-east-1"; } else { // eu-west-1 can be sometimes 'EU'. if (location == "EU") { region = "eu-west-1"; } else { region = location; } } // Add the new location. Instance.Add(bucketName, region); } return(region); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("object-lock", ""); string body = utils.MarshalXML(this.LockConfiguration, "http://s3.amazonaws.com/doc/2006-03-01/"); // Convert string to a byte array // byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); // requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); // requestMessageBuilder.SetBody(bodyInBytes); // // string body = utils.MarshalXML(config, "http://s3.amazonaws.com/doc/2006-03-01/"); requestMessageBuilder.AddXmlBody(body); requestMessageBuilder.AddOrUpdateHeaderParameter("Content-Md5", utils.getMD5SumStr(Encoding.UTF8.GetBytes(body))); // return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("replication", ""); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("lifecycle", ""); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("versioning", ""); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { requestMessageBuilder.AddQueryParameter("object-lock", ""); return(requestMessageBuilder); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { // using System.Web; Not sure if we need to add query parameters like this vs. requestMessageBuilder.AddQueryParameter() // var query = HttpUtility.ParseQueryString(string.Empty); // query["foo"] = "bar<>&-baz"; // query["bar"] = "bazinga"; // string queryString = query.ToString(); { requestMessageBuilder.AddQueryParameter("delimiter", this.Delimiter); requestMessageBuilder.AddQueryParameter("max-keys", "1000"); requestMessageBuilder.AddQueryParameter("encoding-type", "url"); if (!string.IsNullOrWhiteSpace(this.Prefix)) { requestMessageBuilder.AddQueryParameter("prefix", this.Prefix); } if (this.Versions) { requestMessageBuilder.AddQueryParameter("versions", ""); if (!string.IsNullOrWhiteSpace(this.Marker)) { requestMessageBuilder.AddQueryParameter("key-marker", this.Marker); } if (!string.IsNullOrWhiteSpace(this.VersionIdMarker)) { requestMessageBuilder.AddQueryParameter("version-id-marker", this.VersionIdMarker); } } else if (!this.Versions && this.UseV2) { requestMessageBuilder.AddQueryParameter("list-type", "2"); if (!string.IsNullOrWhiteSpace(this.Marker)) { requestMessageBuilder.AddQueryParameter("start-after", this.Marker); } if (!string.IsNullOrWhiteSpace(this.ContinuationToken)) { requestMessageBuilder.AddQueryParameter("continuation-token", this.ContinuationToken); } } else if (!this.Versions && !this.UseV2) { requestMessageBuilder.AddQueryParameter("marker", this.Marker); } else { throw new InvalidOperationException("Wrong set of properties set."); } return(requestMessageBuilder); }