Skip to content

Commit

Permalink
Bump up Restsharp dependency to 106.10.1 (#389)
Browse files Browse the repository at this point in the history
Fixes #384,#386
  • Loading branch information
poornas committed Apr 14, 2020
1 parent 8e71982 commit 1468c43
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 118 deletions.
70 changes: 29 additions & 41 deletions Minio/ApiEndpoints/BucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task<bool> BucketExistsAsync(string bucketName, CancellationToken c
/// <returns>Task</returns>
public async Task RemoveBucketAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))
{
var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null).ConfigureAwait(false);
var request = await this.CreateRequest(Method.DELETE, bucketName).ConfigureAwait(false);

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -212,8 +212,7 @@ public IObservable<Item> ListObjectsAsync(string bucketName, string prefix = nul
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
private async Task<Tuple<ListBucketResult, List<Item>>> GetObjectListAsync(string bucketName, string prefix, string delimiter, string marker, CancellationToken cancellationToken = default(CancellationToken))
{
var queries = new List<string>();

var queryMap = new Dictionary<string,string>();
// null values are treated as empty strings.
if (delimiter == null)
{
Expand All @@ -229,20 +228,16 @@ public IObservable<Item> ListObjectsAsync(string bucketName, string prefix = nul
{
marker = string.Empty;
}

queries.Add("delimiter=" + Uri.EscapeDataString(delimiter));
queries.Add("prefix=" + Uri.EscapeDataString(prefix));
queries.Add("max-keys=1000");
queries.Add("marker=" + Uri.EscapeDataString(marker));
queries.Add("encoding-type=url");

string query = string.Join("&", queries);


var request = await this.CreateRequest(Method.GET,
bucketName,
resourcePath: "?" + query)
bucketName)
.ConfigureAwait(false);

request.AddQueryParameter("delimiter",Uri.EscapeDataString(delimiter));
request.AddQueryParameter("prefix", Uri.EscapeDataString(prefix));
request.AddQueryParameter("max-keys", "1000");
request.AddQueryParameter("marker",Uri.EscapeDataString(marker));
request.AddQueryParameter("encoding-type","url");

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);

var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
Expand Down Expand Up @@ -286,13 +281,10 @@ public async Task<string> GetPolicyAsync(string bucketName, CancellationToken ca
{
IRestResponse response = null;

var path = $"{bucketName}?policy";

var request = await this.CreateRequest(Method.GET, bucketName,
contentType: "application/json",
resourcePath: "?policy")
contentType: "application/json")
.ConfigureAwait(false);

request.AddQueryParameter("policy","");
string policyString = null;
response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
Expand All @@ -315,11 +307,10 @@ public async Task<string> GetPolicyAsync(string bucketName, CancellationToken ca
public async Task SetPolicyAsync(string bucketName, string policyJson, CancellationToken cancellationToken = default(CancellationToken))
{
var request = await this.CreateRequest(Method.PUT, bucketName,
resourcePath: "?policy",
contentType: "application/json",
body: policyJson)
contentType: "application/json")
.ConfigureAwait(false);

request.AddQueryParameter("policy","");
request.AddJsonBody(policyJson);
IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}

Expand All @@ -333,9 +324,9 @@ public async Task<BucketNotification> GetBucketNotificationsAsync(string bucketN
{
utils.ValidateBucketName(bucketName);
var request = await this.CreateRequest(Method.GET,
bucketName,
resourcePath: "?notification")
bucketName)
.ConfigureAwait(false);
request.AddQueryParameter("notification","");

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
Expand All @@ -355,13 +346,14 @@ public async Task<BucketNotification> GetBucketNotificationsAsync(string bucketN
public async Task SetBucketNotificationsAsync(string bucketName, BucketNotification notification, CancellationToken cancellationToken = default(CancellationToken))
{
utils.ValidateBucketName(bucketName);
var request = await this.CreateRequest(Method.PUT, bucketName,
resourcePath: "?notification")
var request = await this.CreateRequest(Method.PUT, bucketName)
.ConfigureAwait(false);
request.AddQueryParameter("notification","");

var bodyString = notification.ToString();

request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer();
request.RequestFormat = DataFormat.Xml;
request.AddBody(notification);
var body = System.Text.Encoding.UTF8.GetBytes(bodyString);
request.AddParameter("application/xml", body, RestSharp.ParameterType.RequestBody);

IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -399,19 +391,15 @@ public IObservable<MinioNotificationRaw> ListenBucketNotificationsAsync(string b
{
while (isRunning)
{
var queries = new List<string>();
queries.Add("prefix=" + Uri.EscapeDataString(prefix));
queries.Add("suffix=" + Uri.EscapeDataString(suffix));
var request = await this.CreateRequest(Method.GET,
bucketName)
.ConfigureAwait(false);
request.AddQueryParameter("prefix",prefix);
request.AddQueryParameter("sufffix",suffix);
foreach (var eventType in events)
{
queries.Add("events=" + Uri.EscapeDataString(eventType.value));
request.AddQueryParameter("events",eventType.value);
}
string query = string.Join("&", queries);
var request = await this.CreateRequest(Method.GET,
bucketName,
resourcePath: "?" + query)
.ConfigureAwait(false);
var startTime = DateTime.Now;
// Logs full url when HTTPtracing is enabled (as in MinioClient.ExecuteTaskAsync)
Expand Down
Loading

0 comments on commit 1468c43

Please sign in to comment.