Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Examples #319

Merged
merged 1 commit into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/BucketExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async static Task Run(MinioClient minio,
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Minio.Examples/Cases/CopyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: CopyObjectAsync");
// Optionally pass copy conditions
await minio.CopyObjectAsync(fromBucketName,
fromObjectName,
destBucketName,
destObjectName,
copyConditions:null,
await minio.CopyObjectAsync(fromBucketName,
fromObjectName,
destBucketName,
destObjectName,
copyConditions: null,
sseSrc: sseSrc,
sseDest: sseDest);
Console.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName);
Console.WriteLine();
Console.WriteLine();
}
catch (Exception e)
{
Expand Down
8 changes: 5 additions & 3 deletions Minio.Examples/Cases/CopyObjectMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async static Task Run(MinioClient minio,
Console.WriteLine("Running example for API: CopyObjectAsync");

// Optionally pass copy conditions to replace metadata on destination object with custom metadata
CopyConditions copyCond = new CopyConditions();
var copyCond = new CopyConditions();
copyCond.SetReplaceMetadataDirective();

// set custom metadata
Expand All @@ -44,18 +44,20 @@ public async static Task Run(MinioClient minio,
{ "Content-Type", "application/css" },
{ "X-Amz-Meta-Mynewkey", "my-new-value" }
};

await minio.CopyObjectAsync(fromBucketName,
fromObjectName,
destBucketName,
destObjectName,
copyConditions:copyCond,
metadata: metadata);
Console.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName);

Console.WriteLine($"Copied object {fromObjectName} from bucket {fromBucketName} to bucket {destBucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Minio.Examples/Cases/CustomRequestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async static Task Run(MinioClient minio)
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/FGetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public async static Task Run(MinioClient minio,
Console.WriteLine("Running example for API: GetObjectAsync");
File.Delete(fileName);
await minio.GetObjectAsync(bucketName, objectName, fileName, sse: sse);
Console.WriteLine("Downloaded the file " + fileName + " from bucket " + bucketName);
Console.WriteLine($"Downloaded the file {fileName} from bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/FPutObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Minio.Examples.Cases
{
class FPutObject
{

// Upload object to bucket from file
public async static Task Run(MinioClient minio,
string bucketName = "my-bucket-name",
Expand All @@ -35,12 +34,13 @@ await minio.PutObjectAsync(bucketName,
objectName,
fileName,
contentType: "application/octet-stream");
Console.WriteLine("Uploaded object " + objectName + " to bucket " + bucketName);

Console.WriteLine($"Uploaded object {objectName} to bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/GetBucketNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: GetBucketNotificationsAsync");
BucketNotification notifications = await minio.GetBucketNotificationsAsync(bucketName);
Console.WriteLine("Notifications is " + notifications.ToXML() + " for bucket " + bucketName);
Console.WriteLine($"Notifications is {notifications.ToXML()} for bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("Error parsing bucket notifications - make sure that you are running this call against AWS end point: " + e.Message);
Console.WriteLine($"Error parsing bucket notifications - make sure that you are running this call against AWS end point: {e.Message}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/GetBucketPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public async static Task Run(MinioClient minio,
try
{
Console.WriteLine("Running example for API: GetPolicyAsync");
String policyJson = await minio.GetPolicyAsync(bucketName);
Console.WriteLine("Current Policy is " + policyJson + " for bucket " + bucketName);
string policyJson = await minio.GetPolicyAsync(bucketName);
Console.WriteLine($"Current Policy is {policyJson} for bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/GetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ await minio.GetObjectAsync(bucketName, objectName,
// Uncomment to print the file on output console
// stream.CopyTo(Console.OpenStandardOutput());
});
Console.WriteLine("Downloaded the file " + fileName + " in bucket " + bucketName);
Console.WriteLine($"Downloaded the file {fileName} in bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/GetPartialObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ await minio.GetObjectAsync(bucketName, objectName, 1024L, 4096L,
var fileStream = File.Create(fileName);
stream.CopyTo(fileStream);
fileStream.Dispose();
FileInfo writtenInfo = new FileInfo(fileName);
var writtenInfo = new FileInfo(fileName);
long file_read_size = writtenInfo.Length;
// 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 {writtenInfo.Length} into file");
stream.Dispose();
});
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions Minio.Examples/Cases/ListBuckets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

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

Expand All @@ -29,15 +28,15 @@ public async static Task Run(MinioClient minio)
{
Console.WriteLine("Running example for API: ListBucketsAsync");
var list = await minio.ListBucketsAsync();
foreach (Bucket bucket in list.Buckets)
foreach (var bucket in list.Buckets)
{
Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
Console.WriteLine($"{bucket.Name} {bucket.CreationDateDateTime}");
}
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Minio.Examples/Cases/ListIncompleteUploads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public static void Run(MinioClient minio,
IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName, prefix, recursive);

IDisposable subscription = observable.Subscribe(
item => Console.WriteLine("OnNext: {0}", item.Key),
ex => Console.WriteLine("OnError: {0}", ex.Message),
() => Console.WriteLine("Listed the pending uploads to bucket " + bucketName));
item => Console.WriteLine($"OnNext: {item.Key}"),
ex => Console.WriteLine($"OnError: {ex.Message}"),
() => Console.WriteLine($"Listed the pending uploads to bucket {bucketName}"));

Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("Exception: {0}", e);
Console.WriteLine($"Exception: {e}");
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions Minio.Examples/Cases/ListObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace Minio.Examples.Cases
{

class ListObjects
{
// List objects matching optional prefix in a specified bucket.
Expand All @@ -34,15 +33,15 @@ public static void Run(MinioClient minio,
IObservable<Item> observable = minio.ListObjectsAsync(bucketName, prefix, recursive);

IDisposable subscription = observable.Subscribe(
item => Console.WriteLine("Object: {0}", item.Key),
ex => Console.WriteLine("OnError: {0}", ex),
() => Console.WriteLine("Listed all objects in bucket " + bucketName + "\n"));
item => Console.WriteLine($"Object: {item.Key}"),
ex => Console.WriteLine($"OnError: {ex}"),
() => Console.WriteLine($"Listed all objects in bucket {bucketName}\n"));

// subscription.Dispose();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/MakeBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: MakeBucketAsync");
await minio.MakeBucketAsync(bucketName);
Console.WriteLine("Created bucket " + bucketName);
Console.WriteLine($"Created bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/PresignedGetObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public async static Task Run(MinioClient client,
try
{
var reqParams = new Dictionary<string, string> { {"response-content-type", "application/json" } };
string presigned_url = await client.PresignedGetObjectAsync(bucketName, objectName, 1000, reqParams);
Console.WriteLine(presigned_url);
string presignedUrl = await client.PresignedGetObjectAsync(bucketName, objectName, 1000, reqParams);
Console.WriteLine(presignedUrl);
}
catch (Exception e)
{
Console.WriteLine("Exception ", e.Message);
Console.WriteLine($"Exception {e.Message}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/PresignedPostPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ 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 + $" -F {pair.Key}={pair.Value}";
}
curlCommand = curlCommand + " -F file=@/etc/bashrc " + tuple.Item1; // https://s3.amazonaws.com/my-bucketname";
Console.WriteLine(curlCommand);
}
catch (Exception e)
{
Console.WriteLine("Exception ", e.Message);
Console.WriteLine($"Exception {e.Message}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/PresignedPutObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public async static Task Run(MinioClient client,
{
try
{
string presigned_url = await client.PresignedPutObjectAsync(bucketName, objectName, 1000);
Console.WriteLine(presigned_url);
string presignedUrl = await client.PresignedPutObjectAsync(bucketName, objectName, 1000);
Console.WriteLine(presignedUrl);
}
catch (Exception e)
{
Console.WriteLine("Exception ", e.Message);
Console.WriteLine($"Exception {e.Message}");
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions Minio.Examples/Cases/PutObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,27 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: PutObjectAsync with Stream and MultiPartUpload");
}

var metaData = new Dictionary<string, string>
{
{ "X-Amz-Meta-Test", "Test Test" }
};

await minio.PutObjectAsync(bucketName,
objectName,
filestream,
filestream.Length,
"application/octet-stream",
metaData: metaData,
sse:sse);
sse: sse);
}

Console.WriteLine("Uploaded object " + objectName + " to bucket " + bucketName);
Console.WriteLine($"Uploaded object {objectName} to bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/RemoveAllBucketNotifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public async static Task Run(MinioClient minio,

await minio.RemoveAllBucketNotificationsAsync(bucketName);

Console.WriteLine("Notifications successfully removed from the bucket " + bucketName);
Console.WriteLine($"Notifications successfully removed from the bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/RemoveBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public async static Task Run(MinioClient minio,
try
{
await minio.RemoveBucketAsync(bucketName);
Console.WriteLine("Removed the bucket " + bucketName + " successfully");
Console.WriteLine($"Removed the bucket {bucketName} successfully");
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
Console.WriteLine($"[Bucket] Exception: {e}");
}
}
}
Expand Down
Loading