diff --git a/Minio/ApiEndpoints/BucketOperations.cs b/Minio/ApiEndpoints/BucketOperations.cs
index b6082e67b..a8c0c56e1 100644
--- a/Minio/ApiEndpoints/BucketOperations.cs
+++ b/Minio/ApiEndpoints/BucketOperations.cs
@@ -50,7 +50,7 @@ public partial class MinioClient : IBucketOperations
//PrepareClient();
var request = new RestRequest("/", Method.GET);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
ListAllMyBucketsResult bucketList = new ListAllMyBucketsResult();
if (HttpStatusCode.OK.Equals(response.StatusCode))
@@ -86,7 +86,7 @@ public partial class MinioClient : IBucketOperations
request.AddBody(config);
}
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
@@ -101,9 +101,8 @@ public partial class MinioClient : IBucketOperations
{
try
{
- var request = await this.CreateRequest(Method.HEAD,
- bucketName);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var request = await this.CreateRequest(Method.HEAD, bucketName).ConfigureAwait(false);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
@@ -124,9 +123,9 @@ public partial class MinioClient : IBucketOperations
/// Task
public async Task RemoveBucketAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))
{
- var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null);
+ var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null).ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
@@ -147,7 +146,7 @@ public partial class MinioClient : IBucketOperations
string marker = null;
while (isRunning)
{
- Tuple> result = await GetObjectListAsync(bucketName, prefix, recursive, marker, cancellationToken);
+ Tuple> result = await GetObjectListAsync(bucketName, prefix, recursive, marker, cancellationToken).ConfigureAwait(false);
Item lastItem = null;
foreach (Item item in result.Item2)
{
@@ -203,11 +202,10 @@ public partial class MinioClient : IBucketOperations
var request = await this.CreateRequest(Method.GET,
bucketName,
- resourcePath: "?" + query);
-
-
-
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ resourcePath: "?" + query)
+ .ConfigureAwait(false);
+
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
ListBucketResult listBucketResult = null;
@@ -254,9 +252,10 @@ public partial class MinioClient : IBucketOperations
var request = await this.CreateRequest(Method.GET, bucketName,
contentType: "application/json",
- resourcePath: "?policy");
+ resourcePath: "?policy")
+ .ConfigureAwait(false);
string policyString = null;
- response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
using (var stream = new MemoryStream(contentBytes))
@@ -278,9 +277,10 @@ public partial class MinioClient : IBucketOperations
var request = await this.CreateRequest(Method.PUT, bucketName,
resourcePath: "?policy",
contentType: "application/json",
- body: policyJson);
+ body: policyJson)
+ .ConfigureAwait(false);
- IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
///
@@ -294,10 +294,11 @@ public partial class MinioClient : IBucketOperations
utils.validateBucketName(bucketName);
var request = await this.CreateRequest(Method.GET,
bucketName,
- resourcePath: "?notification");
+ resourcePath: "?notification")
+ .ConfigureAwait(false);
BucketNotification notification = null;
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
using (var stream = new MemoryStream(contentBytes))
{
@@ -316,13 +317,14 @@ public partial class MinioClient : IBucketOperations
{
utils.validateBucketName(bucketName);
var request = await this.CreateRequest(Method.PUT, bucketName,
- resourcePath: "?notification");
+ resourcePath: "?notification")
+ .ConfigureAwait(false);
request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer();
request.RequestFormat = DataFormat.Xml;
request.AddBody(notification);
- IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
///
@@ -335,7 +337,7 @@ public partial class MinioClient : IBucketOperations
{
utils.validateBucketName(bucketName);
BucketNotification notification = new BucketNotification();
- await SetBucketNotificationsAsync(bucketName, notification, cancellationToken);
+ await SetBucketNotificationsAsync(bucketName, notification, cancellationToken).ConfigureAwait(false);
}
}
}
\ No newline at end of file
diff --git a/Minio/ApiEndpoints/ObjectOperations.cs b/Minio/ApiEndpoints/ObjectOperations.cs
index 13668196f..cf674f220 100644
--- a/Minio/ApiEndpoints/ObjectOperations.cs
+++ b/Minio/ApiEndpoints/ObjectOperations.cs
@@ -49,10 +49,11 @@ public partial class MinioClient : IObjectOperations
{
var request = await this.CreateRequest(Method.GET,
bucketName,
- objectName: objectName);
+ objectName: objectName)
+ .ConfigureAwait(false);
request.ResponseWriter = cb;
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
@@ -79,10 +80,11 @@ public partial class MinioClient : IObjectOperations
var request = await this.CreateRequest(Method.GET,
bucketName,
objectName: objectName,
- headerMap: headerMap);
+ headerMap: headerMap)
+ .ConfigureAwait(false);
request.ResponseWriter = cb;
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
///
@@ -99,7 +101,7 @@ public partial class MinioClient : IObjectOperations
bool fileExists = File.Exists(fileName);
utils.ValidateFile(fileName);
- ObjectStat objectStat = await StatObjectAsync(bucketName, objectName, cancellationToken);
+ ObjectStat objectStat = await StatObjectAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false);
long length = objectStat.Size;
string etag = objectStat.ETag;
@@ -157,7 +159,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
+ ", written = " + writtenSize);
}
utils.MoveWithReplace(tempFileName, fileName);
- }, cancellationToken);
+ }, cancellationToken).ConfigureAwait(false);
}
///
@@ -176,7 +178,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
long size = fileInfo.Length;
using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
- await PutObjectAsync(bucketName, objectName, file, size, contentType, metaData, cancellationToken);
+ await PutObjectAsync(bucketName, objectName, file, size, contentType, metaData, cancellationToken).ConfigureAwait(false);
}
}
@@ -224,7 +226,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
{
throw new UnexpectedShortReadException("Data read " + bytes.Length + " is shorter than the size " + size + " of input buffer.");
}
- await this.PutObjectAsync(bucketName, objectName, null, 0, bytes, metaData, cancellationToken);
+ await this.PutObjectAsync(bucketName, objectName, null, 0, bytes, metaData, cancellationToken).ConfigureAwait(false);
return;
}
// For all sizes greater than 5MiB do multipart.
@@ -237,11 +239,11 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
Part part = null;
Part[] existingParts = null;
- string uploadId = await this.getLatestIncompleteUploadIdAsync(bucketName, objectName, cancellationToken);
+ string uploadId = await this.getLatestIncompleteUploadIdAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false);
if (uploadId == null)
{
- uploadId = await this.NewMultipartUploadAsync(bucketName, objectName, metaData, cancellationToken);
+ uploadId = await this.NewMultipartUploadAsync(bucketName, objectName, metaData, cancellationToken).ConfigureAwait(false);
}
else
{
@@ -288,7 +290,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
if (!skipUpload)
{
numPartsUploaded += 1;
- string etag = await this.PutObjectAsync(bucketName, objectName, uploadId, partNumber, dataToCopy, metaData, cancellationToken);
+ string etag = await this.PutObjectAsync(bucketName, objectName, uploadId, partNumber, dataToCopy, metaData, cancellationToken).ConfigureAwait(false);
totalParts[partNumber - 1] = new Part() { PartNumber = partNumber, ETag = etag, size = (long)expectedReadSize };
}
@@ -296,7 +298,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
// This shouldn't happen where stream size is known.
if (partCount != numPartsUploaded && size != -1)
{
- await this.RemoveUploadAsync(bucketName, objectName, uploadId, cancellationToken);
+ await this.RemoveUploadAsync(bucketName, objectName, uploadId, cancellationToken).ConfigureAwait(false);
return;
}
@@ -305,7 +307,7 @@ await GetObjectAsync(bucketName, objectName, (stream) =>
{
etags[partNumber] = totalParts[partNumber - 1].ETag;
}
- await this.CompleteMultipartUploadAsync(bucketName, objectName, uploadId, etags, cancellationToken);
+ await this.CompleteMultipartUploadAsync(bucketName, objectName, uploadId, etags, cancellationToken).ConfigureAwait(false);
}
///
@@ -323,8 +325,8 @@ private async Task CompleteMultipartUploadAsync(string bucketName, string object
string resourcePath = "?uploadId=" + uploadId;
var request = await this.CreateRequest(Method.POST, bucketName,
objectName: objectName,
- resourcePath: resourcePath
- );
+ resourcePath: resourcePath)
+ .ConfigureAwait(false);
List parts = new List();
@@ -343,7 +345,7 @@ private async Task CompleteMultipartUploadAsync(string bucketName, string object
request.AddParameter("application/xml", body, RestSharp.ParameterType.RequestBody);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
@@ -366,7 +368,7 @@ private IObservable ListParts(string bucketName, string objectName, string
bool isRunning = true;
while (isRunning)
{
- var uploads = await this.GetListPartsAsync(bucketName, objectName, uploadId, nextPartNumberMarker, cancellationToken);
+ var uploads = await this.GetListPartsAsync(bucketName, objectName, uploadId, nextPartNumberMarker, cancellationToken).ConfigureAwait(false);
foreach (Part part in uploads.Item2)
{
obs.OnNext(part);
@@ -396,10 +398,10 @@ private async Task>> GetListPartsAsync(string
resourcePath += "&max-parts=1000";
var request = await this.CreateRequest(Method.GET, bucketName,
objectName: objectName,
- resourcePath: resourcePath
- );
+ resourcePath: resourcePath)
+ .ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
ListPartsResult listPartsResult = null;
@@ -434,9 +436,9 @@ private async Task NewMultipartUploadAsync(string bucketName, string obj
var resource = "?uploads";
var request = await this.CreateRequest(Method.POST, bucketName, objectName: objectName,
- headerMap: metaData, resourcePath: resource);
+ headerMap: metaData, resourcePath: resource).ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
InitiateMultipartUploadResult newUpload = null;
@@ -475,10 +477,10 @@ private async Task PutObjectAsync(string bucketName, string objectName,
contentType: contentType,
headerMap: metaData,
body: data,
- resourcePath: resource
- );
+ resourcePath: resource)
+ .ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
string etag = null;
foreach (Parameter parameter in response.Headers)
@@ -533,10 +535,9 @@ private async Task>> GetMultipart
string query = string.Join("&", queries);
- var request = await this.CreateRequest(Method.GET, bucketName,
- resourcePath: "?" + query);
+ var request = await this.CreateRequest(Method.GET, bucketName, resourcePath: "?" + query).ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
ListMultipartUploadsResult listBucketResult = null;
@@ -594,7 +595,7 @@ private IObservable listIncompleteUploads(string bucketName, string pref
while (isRunning)
{
- var uploads = await this.GetMultipartUploadsListAsync(bucketName, prefix, nextKeyMarker, nextUploadIdMarker, delimiter, cancellationToken);
+ var uploads = await this.GetMultipartUploadsListAsync(bucketName, prefix, nextKeyMarker, nextUploadIdMarker, delimiter, cancellationToken).ConfigureAwait(false);
foreach (Upload upload in uploads.Item2)
{
obs.OnNext(upload);
@@ -651,7 +652,7 @@ private async Task getLatestIncompleteUploadIdAsync(string bucketName, s
{
if (objectName == upload.Key)
{
- await this.RemoveUploadAsync(bucketName, objectName, upload.UploadId, cancellationToken);
+ await this.RemoveUploadAsync(bucketName, objectName, upload.UploadId, cancellationToken).ConfigureAwait(false);
}
}
}
@@ -671,10 +672,10 @@ private async Task RemoveUploadAsync(string bucketName, string objectName, strin
var request = await this.CreateRequest(Method.DELETE, bucketName,
objectName: objectName,
- resourcePath: resourcePath
- );
+ resourcePath: resourcePath)
+ .ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
@@ -688,10 +689,9 @@ private async Task RemoveUploadAsync(string bucketName, string objectName, strin
public async Task RemoveObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default(CancellationToken))
{
- var request = await this.CreateRequest(Method.DELETE, bucketName,
- objectName: objectName);
+ var request = await this.CreateRequest(Method.DELETE, bucketName, objectName: objectName).ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
///
@@ -704,7 +704,7 @@ private async Task RemoveUploadAsync(string bucketName, string objectName, strin
private async Task> removeObjectsAsync(string bucketName, List objectsList, CancellationToken cancellationToken)
{
string resource = "?delete";
- var request = await this.CreateRequest(Method.POST, bucketName, resourcePath: resource);
+ var request = await this.CreateRequest(Method.POST, bucketName, resourcePath: resource).ConfigureAwait(false);
List objects = new List();
foreach (var obj in objectsList)
@@ -720,7 +720,7 @@ private async Task> removeObjectsAsync(string bucketName, List
var body = System.Text.Encoding.UTF8.GetBytes(bodyString);
request.AddParameter("application/xml", body, RestSharp.ParameterType.RequestBody);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
DeleteObjectsResult deleteResult = null;
using (var stream = new MemoryStream(contentBytes))
@@ -769,7 +769,7 @@ private async Task> removeObjectsAsync(string bucketName, List
}
if (objectList.Count() > 0)
{
- var errorsList = await removeObjectsAsync(bucketName, objectList, cancellationToken);
+ var errorsList = await removeObjectsAsync(bucketName, objectList, cancellationToken).ConfigureAwait(false);
foreach (DeleteError error in errorsList)
{
obs.OnNext(error);
@@ -790,10 +790,9 @@ private async Task> removeObjectsAsync(string bucketName, List
/// Facts about the object
public async Task StatObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default(CancellationToken))
{
- var request = await this.CreateRequest(Method.HEAD, bucketName,
- objectName: objectName);
+ var request = await this.CreateRequest(Method.HEAD, bucketName, objectName: objectName).ConfigureAwait(false);
- var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
+ var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
// Extract stats from response
@@ -906,7 +905,7 @@ internal byte[] ReadFull(Stream data, int currentPartSize)
}
// Get Stats on the source object
- ObjectStat srcStats = await this.StatObjectAsync(bucketName, objectName, cancellationToken);
+ ObjectStat srcStats = await this.StatObjectAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false);
long srcByteRangeSize = 0L;
@@ -922,9 +921,9 @@ internal byte[] ReadFull(Stream data, int currentPartSize)
if ((copySize > Constants.MaxSingleCopyObjectSize) ||
(srcByteRangeSize > 0 && (srcByteRangeSize != srcStats.Size)))
- await MultipartCopyUploadAsync(bucketName, objectName, destBucketName, destObjectName, copyConditions, copySize, cancellationToken);
+ await MultipartCopyUploadAsync(bucketName, objectName, destBucketName, destObjectName, copyConditions, copySize, cancellationToken).ConfigureAwait(false);
else
- await this.CopyObjectRequestAsync(bucketName, objectName, destBucketName, destObjectName, copyConditions, null, null, cancellationToken, typeof(CopyObjectResult));
+ await this.CopyObjectRequestAsync(bucketName, objectName, destBucketName, destObjectName, copyConditions, null, null, cancellationToken, typeof(CopyObjectResult)).ConfigureAwait(false);
}
///
/// Create the copy request,execute it and
@@ -955,8 +954,8 @@ private async Task