Skip to content

Commit

Permalink
Cleanup code, fix missing using BucketNotification ToXML (#301)
Browse files Browse the repository at this point in the history
Remove unused namespaces, fix summary, cleanup code
and switch from UInt64 to ulong
  • Loading branch information
tinohager authored and kannappanr committed May 3, 2019
1 parent 71e87e0 commit 8637640
Show file tree
Hide file tree
Showing 58 changed files with 523 additions and 481 deletions.
21 changes: 11 additions & 10 deletions Minio/AWSS3Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Collections.Concurrent;

namespace Minio
{

/**
* Amazon AWS S3 endpoints for various regions.
*/
/// <summary>
/// Amazon AWS S3 endpoints for various regions.
/// </summary>
public sealed class AWSS3Endpoints
{
private static readonly Lazy<AWSS3Endpoints> lazy =
Expand All @@ -33,6 +33,7 @@ public static AWSS3Endpoints Instance
{
get { return lazy.Value; }
}

private AWSS3Endpoints()
{
endpoints = new ConcurrentDictionary<string, string>();
Expand Down Expand Up @@ -68,12 +69,13 @@ private AWSS3Endpoints()
endpoints.TryAdd("cn-north-1", "s3.cn-north-1.amazonaws.com.cn");
}

/**
* Gets Amazon S3 endpoint for the relevant region.
*/
/// <summary>
/// Gets Amazon S3 endpoint for the relevant region.
/// </summary>
/// <param name="region"></param>
/// <returns></returns>
public string endpoint(string region)
{

string endpoint = null;
if (region != null)
{
Expand All @@ -85,6 +87,5 @@ public string endpoint(string region)
}
return endpoint;
}

}
}
}
25 changes: 11 additions & 14 deletions Minio/ApiEndpoints/BucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
* limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Minio.DataModel;
using Minio.Exceptions;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Xml.Serialization;
using Minio.Exceptions;
using System.Globalization;
using System.Net;
using System.Reactive.Linq;
using System.Threading;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace Minio
{
Expand Down Expand Up @@ -89,10 +88,8 @@ public async Task MakeBucketAsync(string bucketName, string location = "us-east-
}

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

}


/// <summary>
/// Returns true if the specified bucketName exists, otherwise returns false.
/// </summary>
Expand Down Expand Up @@ -128,7 +125,6 @@ public async Task RemoveBucketAsync(string bucketName, CancellationToken cancell
var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null).ConfigureAwait(false);

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

}

/// <summary>
Expand Down Expand Up @@ -229,7 +225,7 @@ public IObservable<Item> ListObjectsAsync(string bucketName, string prefix = nul
Key = c.Element("{http://s3.amazonaws.com/doc/2006-03-01/}Key").Value,
LastModified = c.Element("{http://s3.amazonaws.com/doc/2006-03-01/}LastModified").Value,
ETag = c.Element("{http://s3.amazonaws.com/doc/2006-03-01/}ETag").Value,
Size = UInt64.Parse(c.Element("{http://s3.amazonaws.com/doc/2006-03-01/}Size").Value, CultureInfo.CurrentCulture),
Size = ulong.Parse(c.Element("{http://s3.amazonaws.com/doc/2006-03-01/}Size").Value, CultureInfo.CurrentCulture),
IsDir = false
});

Expand Down Expand Up @@ -266,8 +262,9 @@ public async Task<String> GetPolicyAsync(string bucketName, CancellationToken ca
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);

using (var stream = new MemoryStream(contentBytes))
using (var streamReader = new StreamReader(stream))
{
policyString = new StreamReader(stream).ReadToEnd();
policyString = await streamReader.ReadToEndAsync();
}
return policyString;
}
Expand Down
6 changes: 3 additions & 3 deletions Minio/ApiEndpoints/IBucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Threading.Tasks;

using Minio.DataModel;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Minio
{
Expand Down Expand Up @@ -108,6 +109,5 @@ public interface IBucketOperations
Task RemoveAllBucketNotificationsAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken));

// Task ListenBucketNotificationsAsync(string bucketName, string prefix = "", string suffix = "", List<Notification> events,CancellationToken cancellationToken = default(CancellationToken));

}
}
16 changes: 5 additions & 11 deletions Minio/ApiEndpoints/IObjectOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Minio.DataModel;
using Minio.Exceptions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Minio.DataModel;
using System.Threading;
using Minio.Exceptions;
using System.Threading.Tasks;

namespace Minio
{
public interface IObjectOperations
{

/// <summary>
/// Get an object. The object will be streamed to the callback given by the user.
/// </summary>
Expand Down Expand Up @@ -59,7 +60,6 @@ public interface IObjectOperations
/// <param name="metaData">Optional Object metadata to be stored. Defaults to null.</param>
/// <param name="sse">Optional Server-side encryption option. Defaults to null.</param>
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>

Task PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType = null, Dictionary<string, string> metaData = null, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
Expand Down Expand Up @@ -106,7 +106,6 @@ public interface IObjectOperations
/// <param name="bucketName">Bucket to remove incomplete uploads from</param>
/// <param name="objectName">Key to remove incomplete uploads from</param>
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>

Task RemoveIncompleteUploadAsync(string bucketName, string objectName, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
Expand All @@ -120,10 +119,8 @@ public interface IObjectOperations
/// <param name="metadata">Optional Object metadata to be stored. Defaults to null.</param>
/// <param name="sseSrc">Optional Server-side encryption option for source. Defaults to null.</param>
/// <param name="sseDest">Optional Server-side encryption option for destination. Defaults to null.</param>

/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
/// <returns></returns>

Task CopyObjectAsync(string bucketName, string objectName, string destBucketName, string destObjectName = null, CopyConditions copyConditions = null, Dictionary<string, string> metadata = null, ServerSideEncryption sseSrc = null, ServerSideEncryption sseDest = null, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
Expand All @@ -148,7 +145,6 @@ public interface IObjectOperations
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
/// <returns></returns>
//Task GetObjectAsync(string bucketName, string objectName, string filePath,ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken));

Task GetObjectAsync(string bucketName, string objectName, string filePath, ServerSideEncryption sse = null ,CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
Expand All @@ -169,13 +165,11 @@ public interface IObjectOperations
/// <param name="bucketName">Bucket to retrieve object from</param>
/// <param name="objectName">Key of object to retrieve</param>
/// <param name="expiresInt">Expiration time in seconds</param>

Task<string> PresignedPutObjectAsync(string bucketName, string objectName, int expiresInt);

/// <summary>
/// Presigned post policy
/// </summary>
Task<Tuple<string, Dictionary<string, string>>> PresignedPostPolicyAsync(PostPolicy policy);

}
}
Loading

0 comments on commit 8637640

Please sign in to comment.