Skip to content

Commit

Permalink
Code cleanup (#303)
Browse files Browse the repository at this point in the history
- Idiomatic style changes 
- Code formatting.
  • Loading branch information
sungam3r authored and kannappanr committed May 8, 2019
1 parent 2ec6a6e commit ec0a599
Show file tree
Hide file tree
Showing 77 changed files with 939 additions and 1,055 deletions.
48 changes: 24 additions & 24 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var s3Client = new MinioClient("s3.amazonaws.com",

| |
|---|
|`public MinioClient(string endpoint, string accessKey = "", string secretKey = "", string region="", string sessionToken="")` |
| Creates MinIO client object with given endpoint.AccessKey,secretKey, region and sessionToken are optional parameters,and can be omitted for anonymous access.
|`public MinioClient(string endpoint, string accessKey = "", string secretKey = "", string region = "", string sessionToken="")` |
| Creates MinIO client object with given endpoint.AccessKey, secretKey, region and sessionToken are optional parameters, and can be omitted for anonymous access.
The client object uses Http access by default. To use Https, chain method WithSSL() to client object to use secure transfer protocol |


Expand Down Expand Up @@ -86,11 +86,11 @@ MinioClient minioClient = new MinioClient("play.min.io:9000",
).WithSSL();

// 3. Initializing minio client with proxy
IWebProxy proxy = new WebProxy("192.168.0.1",8000);
MinioClient minioClient = new MinioClient("my-ip-address:9000","minio","minio123").WithSSL().WithProxy(proxy);
IWebProxy proxy = new WebProxy("192.168.0.1", 8000);
MinioClient minioClient = new MinioClient("my-ip-address:9000", "minio", "minio123").WithSSL().WithProxy(proxy);

// 4. Initializing minio client with temporary credentials
MinioClient minioClient = new MinioClient("my-ip-address:9000","tempuserid","temppasswd",sessionToken:"sessionToken");
MinioClient minioClient = new MinioClient("my-ip-address:9000", "tempuserid", "temppasswd", sessionToken:"sessionToken");
```


Expand All @@ -110,7 +110,7 @@ MinioClient s3Client = new MinioClient("s3.amazonaws.com:80",
## 2. Bucket operations

<a name="makeBucket"></a>
### MakeBucketAsync(string bucketName, string location="us-east-1")
### MakeBucketAsync(string bucketName, string location = "us-east-1")
`Task MakeBucketAsync(string bucketName, string location = "us-east-1", CancellationToken cancellationToken = default(CancellationToken))`

Creates a new bucket.
Expand Down Expand Up @@ -487,7 +487,7 @@ catch (MinioException e)


<a name="setBucketNotification"></a>
### SetBucketNotificationAsync(string bucketName,BucketNotification notification)
### SetBucketNotificationAsync(string bucketName, BucketNotification notification)
`Task SetBucketNotificationAsync(string bucketName, BucketNotification notification, CancellationToken cancellationToken = default(CancellationToken))`

Sets notification configuration for a given bucket
Expand Down Expand Up @@ -677,7 +677,7 @@ try
```

<a name="getObject"></a>
### GetObjectAsync(string bucketName, string objectName, long offset,long length, Action<Stream> callback, ServerSideEncryption sse)
### GetObjectAsync(string bucketName, string objectName, long offset, long length, Action<Stream> callback, ServerSideEncryption sse)

`Task GetObjectAsync(string bucketName, string objectName, long offset, long length, Action<Stream> callback, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))`

Expand Down Expand Up @@ -779,9 +779,9 @@ catch (MinioException e)
}
```
<a name="putObject"></a>
### PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType,ServerSideEncryption sse)
### PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType, ServerSideEncryption sse)

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


Uploads contents from a stream to objectName.
Expand Down Expand Up @@ -833,7 +833,7 @@ try
"island.jpg",
filestream,
filestream.Length,
"application/octet-stream",ssec);
"application/octet-stream", ssec);
Console.Out.WriteLine("island.jpg is uploaded successfully");
}
catch(MinioException e)
Expand All @@ -843,9 +843,9 @@ catch(MinioException e)
```

<a name="putObject"></a>
### PutObjectAsync(string bucketName, string objectName, string filePath, string contentType=null,ServerSideEncryption sse)
### PutObjectAsync(string bucketName, string objectName, string filePath, string contentType=null, ServerSideEncryption sse)

` Task PutObjectAsync(string bucketName, string objectName, string filePath, string contentType=null,Dictionary<string,string> metaData=null, ServerSideEncryption sse=null,CancellationToken cancellationToken = default(CancellationToken))`
` Task PutObjectAsync(string bucketName, string objectName, string filePath, string contentType = null, Dictionary<string, string> metaData = null, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))`


Uploads contents from a file to objectName.
Expand Down Expand Up @@ -883,7 +883,7 @@ The maximum size of a single object is limited to 5TB. putObject transparently u
```cs
try
{
await minio.PutObjectAsync("mybucket", "island.jpg", "/mnt/photos/island.jpg",contentType: "application/octet-stream");
await minio.PutObjectAsync("mybucket", "island.jpg", "/mnt/photos/island.jpg", contentType: "application/octet-stream");
Console.Out.WriteLine("island.jpg is uploaded successfully");
}
catch(MinioException e)
Expand All @@ -892,9 +892,9 @@ catch(MinioException e)
}
```
<a name="statObject"></a>
### StatObjectAsync(string bucketName, string objectName,ServerSideEncryption sse)
### StatObjectAsync(string bucketName, string objectName, ServerSideEncryption sse)

`Task<ObjectStat> StatObjectAsync(string bucketName, string objectName,ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))`
`Task<ObjectStat> StatObjectAsync(string bucketName, string objectName, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))`

Gets metadata of an object.

Expand Down Expand Up @@ -936,9 +936,9 @@ catch(MinioException e)
```

<a name="copyObject"></a>
### CopyObjectAsync(string bucketName, string objectName, string destBucketName, string destObjectName = null, CopyConditions copyConditions = null,Dictionary<string, string> metadata = null, ServerSideEncryption sseSrc = null, ServerSideEncryption sseDest = null)
### CopyObjectAsync(string bucketName, string objectName, string destBucketName, string destObjectName = null, CopyConditions copyConditions = null, Dictionary<string, string> metadata = null, ServerSideEncryption sseSrc = null, ServerSideEncryption sseDest = null)

*`Task<CopyObjectResult> 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))`*
*`Task<CopyObjectResult> 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))`*

Copies content from objectName to destObjectName.

Expand Down Expand Up @@ -977,7 +977,7 @@ try
{
CopyConditions copyConditions = new CopyConditions();
copyConditions.setMatchETagNone("TestETag");
ServerSideEncryption sseSrc,sseDst;
ServerSideEncryption sseSrc, sseDst;
// Uncomment to specify source and destination Server-side encryption options
/*
Aes aesEncryption = Aes.Create();
Expand All @@ -986,7 +986,7 @@ try
sseSrc = new SSEC(aesEncryption.Key);
sseDst = new SSES3();
*/
await minioClient.CopyObjectAsync("mybucket", "island.jpg", "mydestbucket", "processed.png", copyConditions,sseSrc:sseSrc, sseDest:sseDst);
await minioClient.CopyObjectAsync("mybucket", "island.jpg", "mydestbucket", "processed.png", copyConditions, sseSrc:sseSrc, sseDest:sseDst);
Console.Out.WriteLine("island.jpg is uploaded successfully");
}
catch(MinioException e)
Expand Down Expand Up @@ -1130,8 +1130,8 @@ catch(MinioException e)
## 4. Presigned operations
<a name="presignedGetObject"></a>

### PresignedGetObjectAsync(string bucketName, string objectName, int expiresInt, Dictionary<string,string> reqParams = null, DateTime? reqDate = null);
`Task<string> PresignedGetObjectAsync(string bucketName, string objectName, int expiresInt, Dictionary<string,string> reqParams = null, DateTime? reqDate = null)`
### PresignedGetObjectAsync(string bucketName, string objectName, int expiresInt, Dictionary<string, string> reqParams = null, DateTime? reqDate = null);
`Task<string> PresignedGetObjectAsync(string bucketName, string objectName, int expiresInt, Dictionary<string, string> reqParams = null, DateTime? reqDate = null)`

Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.

Expand Down Expand Up @@ -1225,7 +1225,7 @@ __Parameters__

| Return Type | Exceptions |
|:--- |:--- |
| ``Task<Dictionary<string,string>>``: Map of strings to construct form-data. | Listed Exceptions: |
| ``Task<Dictionary<string, string>>``: Map of strings to construct form-data. | Listed Exceptions: |
| | ``InvalidBucketNameException`` : upon invalid bucket name |
| | ``ConnectionException`` : upon connection error |
| | ``NoSuchAlgorithmException`` : upon requested algorithm was not found during signature calculation. |
Expand Down Expand Up @@ -1262,7 +1262,7 @@ catch(MinioException e)
```
## Client Custom Settings
<a name="SetAppInfo"></a>
### SetAppInfo(string appName, tring appVersion)
### SetAppInfo(string appName, string appVersion)
Adds application details to User-Agent.

__Parameters__
Expand Down
2 changes: 1 addition & 1 deletion FileUploader/FileUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void Main(string[] args)
try
{
var minio = new MinioClient(endpoint, accessKey, secretKey).WithSSL();
FileUpload.Run(minio).Wait();
Run(minio).Wait();
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/BucketExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async static Task Run(MinioClient minio,
{
Console.Out.WriteLine("Running example for API: BucketExistsAsync");
bool found = await minio.BucketExistsAsync(bucketName);
Console.Out.WriteLine(((found == true) ? "Found" : "Couldn't find ") + "bucket " + bucketName);
Console.Out.WriteLine((found ? "Found" : "Couldn't find ") + "bucket " + bucketName);
Console.Out.WriteLine();
}
catch (Exception e)
Expand Down
8 changes: 4 additions & 4 deletions Minio.Examples/Cases/CopyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class CopyObject
{
// Copy object from one bucket to another
public async static Task Run(Minio.MinioClient minio,
string fromBucketName="from-bucket-name",
string fromObjectName="from-object-name",
string destBucketName="dest-bucket",
string destObjectName="to-object-name",
string fromBucketName = "from-bucket-name",
string fromObjectName = "from-object-name",
string destBucketName = "dest-bucket",
string destObjectName =" to-object-name",
ServerSideEncryption sseSrc = null,
ServerSideEncryption sseDest = null)
{
Expand Down
14 changes: 7 additions & 7 deletions Minio.Examples/Cases/CopyObjectMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class CopyObjectMetadata
{
// Copy object from one bucket to another
public async static Task Run(Minio.MinioClient minio,
string fromBucketName="from-bucket-name",
string fromObjectName="from-object-name",
string destBucketName="dest-bucket",
string destObjectName="to-object-name")
string fromBucketName = "from-bucket-name",
string fromObjectName = "from-object-name",
string destBucketName = "dest-bucket",
string destObjectName = "to-object-name")
{
try
{
Expand All @@ -38,10 +38,10 @@ public async static Task Run(Minio.MinioClient minio,
copyCond.SetReplaceMetadataDirective();

// set custom metadata
Dictionary<string,string> metadata = new Dictionary<string,string>()
var metadata = new Dictionary<string, string>
{
{ "Content-Type", "application/css"},
{"X-Amz-Meta-Mynewkey","my-new-value"}
{ "Content-Type", "application/css" },
{ "X-Amz-Meta-Mynewkey", "my-new-value" }
};
await minio.CopyObjectAsync(fromBucketName,
fromObjectName,
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/FGetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FGetObject
public async static Task Run(Minio.MinioClient minio,
string bucketName = "my-bucket-name",
string objectName = "my-object-name",
string fileName="local-filename",
string fileName = "local-filename",
ServerSideEncryption sse = null)
{
try
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/GetBucketNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async static Task Run(Minio.MinioClient minio,
}
catch (Exception e)
{
Console.Out.WriteLine("Error parsing bucket notifications - make sure that you are running this call against AWS end point");
Console.Out.WriteLine("Error parsing bucket notifications - make sure that you are running this call against AWS end point: " + e.Message);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/GetBucketPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GetBucketPolicy
// Get bucket policy
public async static Task Run(Minio.MinioClient minio,
string bucketName = "my-bucket-name",
string prefix="")
string prefix = "")
{
try
{
Expand Down
8 changes: 4 additions & 4 deletions Minio.Examples/Cases/GetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ class GetObject
{
// Get object in a bucket
public async static Task Run(MinioClient minio,
string bucketName="my-bucket-name",
string objectName="my-object-name",
string fileName="my-file-name")
string bucketName = "my-bucket-name",
string objectName = "my-object-name",
string fileName = "my-file-name")
{
try
{
Console.Out.WriteLine("Running example for API: GetObjectAsync");
await minio.GetObjectAsync(bucketName, objectName,
(stream) =>
{
// Uncommment to print the file on output console
// Uncomment to print the file on output console
// stream.CopyTo(Console.OpenStandardOutput());
});
Console.WriteLine("Downloaded the file " + fileName + " in bucket " + bucketName);
Expand Down
10 changes: 5 additions & 5 deletions Minio.Examples/Cases/GetPartialObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class GetPartialObject
// Get object in a bucket for a particular offset range. Dotnet SDK currently
// requires both start offset and end
public async static Task Run(MinioClient minio,
string bucketName="my-bucket-name",
string objectName="my-object-name",
string fileName="my-file-name")
string bucketName = "my-bucket-name",
string objectName = "my-object-name",
string fileName = "my-file-name")
{
try
{
Expand All @@ -45,9 +45,9 @@ await minio.GetObjectAsync(bucketName, objectName, 1024L, 4096L,
fileStream.Dispose();
FileInfo writtenInfo = new FileInfo(fileName);
long file_read_size = writtenInfo.Length;
// Uncommment to print the file on output console
// Uncomment to print the file on output console
// stream.CopyTo(Console.OpenStandardOutput());
Console.WriteLine("Successfully downloaded object with requested offset and length {0} into file",writtenInfo.Length);
Console.WriteLine("Successfully downloaded object with requested offset and length {0} into file", writtenInfo.Length);
stream.Dispose();
});
Console.Out.WriteLine();
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/MakeBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MakeBucket
{
// Make a bucket
public async static Task Run(Minio.MinioClient minio,
string bucketName="my-bucket-name")
string bucketName = "my-bucket-name")
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/PresignedGetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async static Task Run(MinioClient client,
{
try
{
Dictionary<string,string> reqParams = new Dictionary<string, string>(){{"response-content-type", "application/json"}};
var reqParams = new Dictionary<string, string> { {"response-content-type", "application/json" } };
string presigned_url = await client.PresignedGetObjectAsync(bucketName, objectName, 1000, reqParams);
Console.Out.WriteLine(presigned_url);
}
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/PresignedPostPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async static Task Run(MinioClient client)
string curlCommand = "curl -X POST ";
foreach (KeyValuePair<string, string> pair in tuple.Item2)
{
curlCommand = curlCommand + String.Format(" -F {0}={1}", pair.Key, pair.Value);
curlCommand = curlCommand + string.Format(" -F {0}={1}", pair.Key, pair.Value);
}
curlCommand = curlCommand + " -F file=@/etc/bashrc " + tuple.Item1; // https://s3.amazonaws.com/my-bucketname";
Console.Out.WriteLine(curlCommand);
Expand Down
Loading

0 comments on commit ec0a599

Please sign in to comment.