Skip to content
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
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"commands": [
"regitlint"
]
},
"csharpier": {
"version": "1.1.2",
"commands": [
"csharpier"
]
}
}
}
8 changes: 4 additions & 4 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1608,14 +1608,14 @@ try
Arn topicArn = new Arn("aws", "sns", "us-west-1", "412334153608", "topicminio");

TopicConfig topicConfiguration = new TopicConfig(topicArn);
List<EventType> events = new List<EventType>(){ EventType.ObjectCreatedPut , EventType.ObjectCreatedCopy };
List<EventType> events = []{ EventType.ObjectCreatedPut , EventType.ObjectCreatedCopy };
topicConfiguration.AddEvents(events);
topicConfiguration.AddFilterPrefix("images");
topicConfiguration.AddFilterSuffix("jpg");
notification.AddTopic(topicConfiguration);

QueueConfig queueConfiguration = new QueueConfig("arn:aws:sqs:us-west-1:482314153608:testminioqueue1");
queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload });
queueConfiguration.AddEvents([] { EventType.ObjectCreatedCompleteMultipartUpload });
notification.AddQueue(queueConfiguration);

SetBucketNotificationsArgs args = new SetBucketNotificationsArgs()
Expand Down Expand Up @@ -2126,11 +2126,11 @@ try
{
string bucketName = "mybucket";
string objectName = "myobject1";
List<string> versionIDs = new List<string>();
List<string> versionIDs = [];
versionIDs.Add("abcobject1version1dce");
versionIDs.Add("abcobject1version2dce");
versionIDs.Add("abcobject1version3dce");
List<Tuple<string, string>> objectsVersions = new List<Tuple<string, string>>();
List<Tuple<string, string>> objectsVersions = [];
objectsVersions.Add(new Tuple<string, List<string>>(objectName, versionIDs));
objectsVersions.Add(new Tuple<string, string>("myobject2" "abcobject2version1dce"));
objectsVersions.Add(new Tuple<string, string>("myobject2", "abcobject2version2dce"));
Expand Down
20 changes: 13 additions & 7 deletions Minio.Examples/Cases/SelectObjectContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ namespace Minio.Examples.Cases;
internal static class SelectObjectContent
{
// Get object in a bucket
public static async Task Run(IMinioClient minio,
public static async Task Run(
IMinioClient minio,
string bucketName = "my-bucket-name",
string objectName = "my-object-name")
string objectName = "my-object-name"
)
{
if (minio is null) throw new ArgumentNullException(nameof(minio));
if (minio is null)
throw new ArgumentNullException(nameof(minio));

var newObjectName = "new" + objectName;
try
Expand Down Expand Up @@ -58,12 +61,14 @@ public static async Task Run(IMinioClient minio,
CompressionType = SelectCompressionType.NONE,
CSV = new CSVInputOptions
{
FileHeaderInfo = CSVFileHeaderInfo.None, RecordDelimiter = "\n", FieldDelimiter = ","
}
FileHeaderInfo = CSVFileHeaderInfo.None,
RecordDelimiter = "\n",
FieldDelimiter = ",",
},
};
var outputSerialization = new SelectObjectOutputSerialization
{
CSV = new CSVOutputOptions { RecordDelimiter = "\n", FieldDelimiter = "," }
CSV = new CSVOutputOptions { RecordDelimiter = "\n", FieldDelimiter = "," },
};
var args = new SelectObjectContentArgs()
.WithBucket(bucketName)
Expand All @@ -78,7 +83,8 @@ public static async Task Run(IMinioClient minio,
Console.WriteLine("Bytes scanned:" + resp.Stats.BytesScanned);
Console.WriteLine("Bytes returned:" + resp.Stats.BytesReturned);
Console.WriteLine("Bytes processed:" + resp.Stats.BytesProcessed);
if (resp.Progress is not null) Console.WriteLine("Progress :" + resp.Progress.BytesProcessed);
if (resp.Progress is not null)
Console.WriteLine("Progress :" + resp.Progress.BytesProcessed);
}
catch (Exception e)
{
Expand Down
6 changes: 3 additions & 3 deletions Minio.Examples/Cases/SetBucketNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ public static async Task Run(IMinioClient minio,
/*
Arn topicArn = new Arn("aws", "sns", "us-west-1", "730234153608", "topicminio");
TopicConfig topicConfiguration = new TopicConfig(topicArn);
List<EventType> events = new List<EventType>(){ EventType.ObjectCreatedPut , EventType.ObjectCreatedCopy };
List<EventType> events = []{ EventType.ObjectCreatedPut , EventType.ObjectCreatedCopy };
topicConfiguration.AddEvents(events);
topicConfiguration.AddFilterPrefix("images");
topicConfiguration.AddFilterSuffix("pg");
notification.AddTopic(topicConfiguration);

LambdaConfig lambdaConfiguration = new LambdaConfig("arn:aws:lambda:us-west-1:123434153608:function:lambdak1");
lambdaConfiguration.AddEvents(new List<EventType>() { EventType.ObjectRemovedDelete });
lambdaConfiguration.AddEvents([] { EventType.ObjectRemovedDelete });
lambdaConfiguration.AddFilterPrefix("java");
lambdaConfiguration.AddFilterSuffix("java");
notification.AddLambda(lambdaConfiguration);

QueueConfig queueConfiguration = new QueueConfig("arn:aws:sqs:us-west-1:123434153608:testminioqueue1");
queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload });
queueConfiguration.AddEvents([] { EventType.ObjectCreatedCompleteMultipartUpload });
notification.AddQueue(queueConfiguration);
*/
await minio.SetBucketNotificationsAsync(args).ConfigureAwait(false);
Expand Down
116 changes: 84 additions & 32 deletions Minio.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ public static string GetRandomName()
{
var characters = "0123456789abcdefghijklmnopqrstuvwxyz";
var result = new StringBuilder(5);
for (var i = 0; i < 5; i++) _ = result.Append(characters[rnd.Next(characters.Length)]);
for (var i = 0; i < 5; i++)
_ = result.Append(characters[rnd.Next(characters.Length)]);
return "minio-dotnet-example-" + result;
}

[SuppressMessage("Design", "MA0051:Method is too long", Justification = "Needs to run all tests")]
[SuppressMessage(
"Design",
"MA0051:Method is too long",
Justification = "Needs to run all tests"
)]
public static async Task Main()
{
string endPoint = null;
Expand All @@ -69,18 +74,23 @@ public static async Task Main()
var posColon = endPoint.LastIndexOf(':');
if (posColon != -1)
{
port = int.Parse(endPoint.Substring(posColon + 1, endPoint.Length - posColon - 1), NumberStyles.Integer,
CultureInfo.InvariantCulture);
port = int.Parse(
endPoint.Substring(posColon + 1, endPoint.Length - posColon - 1),
NumberStyles.Integer,
CultureInfo.InvariantCulture
);
endPoint = endPoint[..posColon];
}

accessKey = Environment.GetEnvironmentVariable("ACCESS_KEY");
secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
if (Environment.GetEnvironmentVariable("ENABLE_HTTPS") is not null)
{
isSecure = Environment.GetEnvironmentVariable("ENABLE_HTTPS")
isSecure = Environment
.GetEnvironmentVariable("ENABLE_HTTPS")
.Equals("1", StringComparison.OrdinalIgnoreCase);
if (isSecure && port == 80) port = 443;
if (isSecure && port == 80)
port = 443;
}
}
else
Expand All @@ -93,8 +103,12 @@ public static async Task Main()
}

#pragma warning disable MA0039 // Do not write your own certificate validation method
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.ServerCertificateValidationCallback += (
sender,
certificate,
chain,
sslPolicyErrors
) => true;
#pragma warning restore MA0039 // Do not write your own certificate validation method

using var minioClient = new MinioClient()
Expand All @@ -103,7 +117,7 @@ public static async Task Main()
.WithSSL(isSecure)
.Build();

// Assign parameters before starting the test
// Assign parameters before starting the test
var bucketName = GetRandomName();
var smallFileName = CreateFile(1 * UNIT_MB);
var bigFileName = CreateFile(6 * UNIT_MB);
Expand All @@ -114,15 +128,18 @@ public static async Task Main()
var progress = new SyncProgress<ProgressReport>(progressReport =>
{
Console.WriteLine(
$"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes");
$"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes"
);
if (progressReport.Percentage != 100)
Console.SetCursorPosition(0, Console.CursorTop - 1);
else Console.WriteLine();
else
Console.WriteLine();
});
var objectsList = new List<string>();
for (var i = 0; i < 10; i++) objectsList.Add(objectName + i);
List<string> objectsList = [];
for (var i = 0; i < 10; i++)
objectsList.Add(objectName + i);

// Set app Info
// Set app Info
_ = minioClient.SetAppInfo("app-name", "app-version");

// Set HTTP Tracing On
Expand Down Expand Up @@ -150,13 +167,19 @@ public static async Task Main()
await ListBuckets.Run(minioClient).ConfigureAwait(false);

// Start listening for bucket notifications
ListenBucketNotifications.Run(minioClient, bucketName, new List<EventType> { EventType.ObjectCreatedAll });
ListenBucketNotifications.Run(
minioClient,
bucketName,
new List<EventType> { EventType.ObjectCreatedAll }
);

// Start listening for global notifications
ListenNotifications.Run(minioClient, new List<EventType> { EventType.BucketCreatedAll });

// Put an object to the new bucket
await PutObject.Run(minioClient, bucketName, objectName, smallFileName, progress).ConfigureAwait(false);
await PutObject
.Run(minioClient, bucketName, objectName, smallFileName, progress)
.ConfigureAwait(false);

// Get object metadata
await StatObject.Run(minioClient, bucketName, objectName).ConfigureAwait(false);
Expand All @@ -165,27 +188,40 @@ public static async Task Main()
await ListObjects.Run(minioClient, bucketName).ConfigureAwait(false);

// Get the file and Download the object as file
await GetObject.Run(minioClient, bucketName, objectName, smallFileName).ConfigureAwait(false);
await GetObject
.Run(minioClient, bucketName, objectName, smallFileName)
.ConfigureAwait(false);
// Select content from object
await SelectObjectContent.Run(minioClient, bucketName, objectName).ConfigureAwait(false);
// Delete the file and Download partial object as file
await GetPartialObject.Run(minioClient, bucketName, objectName, smallFileName).ConfigureAwait(false);
await GetPartialObject
.Run(minioClient, bucketName, objectName, smallFileName)
.ConfigureAwait(false);

// Server side copyObject
await CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName).ConfigureAwait(false);
await CopyObject
.Run(minioClient, bucketName, objectName, destBucketName, objectName)
.ConfigureAwait(false);

// Server side copyObject with metadata replacement
await CopyObjectMetadata.Run(minioClient, bucketName, objectName, destBucketName, objectName)
await CopyObjectMetadata
.Run(minioClient, bucketName, objectName, destBucketName, objectName)
.ConfigureAwait(false);

// Upload a File with PutObject
await FPutObject.Run(minioClient, bucketName, objectName, smallFileName).ConfigureAwait(false);
await FPutObject
.Run(minioClient, bucketName, objectName, smallFileName)
.ConfigureAwait(false);

// Delete the file and Download the object as file
await FGetObject.Run(minioClient, bucketName, objectName, smallFileName).ConfigureAwait(false);
await FGetObject
.Run(minioClient, bucketName, objectName, smallFileName)
.ConfigureAwait(false);

// Automatic Multipart Upload with object more than 5Mb
await PutObject.Run(minioClient, bucketName, objectName, bigFileName, progress).ConfigureAwait(false);
await PutObject
.Run(minioClient, bucketName, objectName, bigFileName, progress)
.ConfigureAwait(false);

// Specify SSE-C encryption options
using var aesEncryption = Aes.Create();
Expand All @@ -200,17 +236,27 @@ await CopyObjectMetadata.Run(minioClient, bucketName, objectName, destBucketName
var sses3 = new SSES3();

// Uncomment to specify SSE-KMS encryption option
var sseKms = new SSEKMS("kms-key",
new Dictionary<string, string>(StringComparer.Ordinal) { { "kms-context", "somevalue" } });
var sseKms = new SSEKMS(
"kms-key",
new Dictionary<string, string>(StringComparer.Ordinal)
{
{ "kms-context", "somevalue" },
}
);

// Upload encrypted object
var putFileName1 = CreateFile(1 * UNIT_MB);
await PutObject.Run(minioClient, bucketName, objectName, putFileName1, progress, ssec).ConfigureAwait(false);
await PutObject
.Run(minioClient, bucketName, objectName, putFileName1, progress, ssec)
.ConfigureAwait(false);
// Copy SSE-C encrypted object to unencrypted object
await CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName, sseCpy, ssec)
await CopyObject
.Run(minioClient, bucketName, objectName, destBucketName, objectName, sseCpy, ssec)
.ConfigureAwait(false);
// Download SSE-C encrypted object
await FGetObject.Run(minioClient, destBucketName, objectName, bigFileName, ssec).ConfigureAwait(false);
await FGetObject
.Run(minioClient, destBucketName, objectName, bigFileName, ssec)
.ConfigureAwait(false);

// List the incomplete uploads
await ListIncompleteUploads.Run(minioClient, bucketName).ConfigureAwait(false);
Expand All @@ -236,16 +282,21 @@ await CopyObject.Run(minioClient, bucketName, objectName, destBucketName, object
lockBucketName = GetRandomName();
await MakeBucketWithLock.Run(minioClient, lockBucketName).ConfigureAwait(false);
var configuration = new ObjectLockConfiguration(ObjectRetentionMode.GOVERNANCE, 35);
await SetObjectLockConfiguration.Run(minioClient, lockBucketName, configuration).ConfigureAwait(false);
await SetObjectLockConfiguration
.Run(minioClient, lockBucketName, configuration)
.ConfigureAwait(false);
await GetObjectLockConfiguration.Run(minioClient, lockBucketName).ConfigureAwait(false);
await RemoveObjectLockConfiguration.Run(minioClient, lockBucketName).ConfigureAwait(false);
await RemoveBucket.Run(minioClient, lockBucketName).ConfigureAwait(false);

// Bucket Replication operations
var replicationRuleID = "myreplicationID-3333";
await SetBucketReplication.Run(minioClient, bucketName, destBucketName, replicationRuleID)
await SetBucketReplication
.Run(minioClient, bucketName, destBucketName, replicationRuleID)
.ConfigureAwait(false);
await GetBucketReplication
.Run(minioClient, bucketName, replicationRuleID)
.ConfigureAwait(false);
await GetBucketReplication.Run(minioClient, bucketName, replicationRuleID).ConfigureAwait(false);
// TODO: we can verify that the replication happens by checking
// the content in the destination matches the source content.
// We also cannot remove the replication config immediately
Expand Down Expand Up @@ -285,6 +336,7 @@ await SetBucketReplication.Run(minioClient, bucketName, destBucketName, replicat
File.Delete(smallFileName);
File.Delete(bigFileName);

if (OperatingSystem.IsWindows()) _ = Console.ReadLine();
if (OperatingSystem.IsWindows())
_ = Console.ReadLine();
}
}
Loading
Loading