diff --git a/Minio.Examples/Cases/SelectObjectContent.cs b/Minio.Examples/Cases/SelectObjectContent.cs index 4cbe19893..5ea94e108 100644 --- a/Minio.Examples/Cases/SelectObjectContent.cs +++ b/Minio.Examples/Cases/SelectObjectContent.cs @@ -61,14 +61,12 @@ public static async Task Run( 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) diff --git a/Minio.Examples/Program.cs b/Minio.Examples/Program.cs index 11e1e2611..b24b38fd0 100644 --- a/Minio.Examples/Program.cs +++ b/Minio.Examples/Program.cs @@ -238,10 +238,7 @@ await PutObject // Uncomment to specify SSE-KMS encryption option var sseKms = new SSEKMS( "kms-key", - new Dictionary(StringComparer.Ordinal) - { - { "kms-context", "somevalue" }, - } + new Dictionary(StringComparer.Ordinal) { { "kms-context", "somevalue" } } ); // Upload encrypted object diff --git a/Minio.Functional.Tests/FunctionalTest.cs b/Minio.Functional.Tests/FunctionalTest.cs index f511c64de..0d35f472d 100644 --- a/Minio.Functional.Tests/FunctionalTest.cs +++ b/Minio.Functional.Tests/FunctionalTest.cs @@ -208,7 +208,7 @@ private static string Bash(string cmd) { "%", "\\%" }, { "&", "\\&" }, { "#", "\\#" }, - { "+", "\\+" }, + { "+", "\\+" } }; foreach (var toReplace in Replacements.Keys) @@ -223,8 +223,8 @@ private static string Bash(string cmd) Arguments = $"-c \"{cmdNoReturn}\"", UseShellExecute = false, RedirectStandardOutput = true, - CreateNoWindow = true, - }, + CreateNoWindow = true + } }; _ = process.Start(); @@ -290,7 +290,7 @@ internal static void GenerateRandom500MB_File(string fileName) FileAccess.Write, FileShare.None, 4096, - useAsync: true + true ); var fileSize = 500L * 1024 * 1024; var segments = fileSize / 10000; @@ -344,7 +344,7 @@ internal static Task RunCoreTests(IMinioClient minioClient) //RemoveIncompleteUpload_Test(minioClient), // Test GetBucket policy - GetBucketPolicy_Test1(minioClient), + GetBucketPolicy_Test1(minioClient) ]; return coreTestsTasks.ForEachAsync(); @@ -357,10 +357,7 @@ internal static async Task BucketExists_Test(IMinioClient minio) var mbArgs = new MakeBucketArgs().WithBucket(bucketName); var beArgs = new BucketExistsArgs().WithBucket(bucketName); var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { @@ -430,10 +427,7 @@ internal static async Task RemoveBucket_Test1(IMinioClient minio) var mbArgs = new MakeBucketArgs().WithBucket(bucketName); var beArgs = new BucketExistsArgs().WithBucket(bucketName); var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; var found = false; try @@ -481,7 +475,7 @@ internal static async Task RemoveBucket_Test2(IMinioClient minio) var objectName = GetRandomName(20); var forceFlagHeader = new Dictionary(StringComparer.Ordinal) { - { "x-minio-force-delete", "true" }, + { "x-minio-force-delete", "true" } }; var beArgs = new BucketExistsArgs().WithBucket(bucketName); @@ -507,8 +501,7 @@ internal static async Task RemoveBucket_Test2(IMinioClient minio) var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "x-minio-force-delete", "true" }, + { "bucketName", bucketName }, { "x-minio-force-delete", "true" } }; var found = false; @@ -561,7 +554,7 @@ internal static async Task ListBuckets_Test(IMinioClient minio) var args = new Dictionary(StringComparer.Ordinal) { { "bucketNameSuffix", bucketNameSuffix }, - { "noOfBuckets", noOfBuckets.ToString(CultureInfo.InvariantCulture) }, + { "noOfBuckets", noOfBuckets.ToString(CultureInfo.InvariantCulture) } }; try @@ -823,7 +816,7 @@ internal static async Task PutGetStatEncryptedObject_Test1(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -933,7 +926,7 @@ internal static async Task PutGetStatEncryptedObject_Test2(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "6MB" }, - { "size", "6MB" }, + { "size", "6MB" } }; try { @@ -1048,7 +1041,7 @@ internal static async Task PutGetStatEncryptedObject_Test3(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "6MB" }, - { "size", "6MB" }, + { "size", "6MB" } }; try { @@ -1255,7 +1248,7 @@ internal static async Task StatObject_Test1(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try @@ -1309,9 +1302,7 @@ internal static async Task FPutObject_Test1(IMinioClient minio) var fileName = CreateFile(6 * MB, dataFile6MB); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "fileName", fileName }, + { "bucketName", bucketName }, { "objectName", objectName }, { "fileName", fileName } }; try { @@ -1360,9 +1351,7 @@ internal static async Task FPutObject_Test2(IMinioClient minio) var fileName = CreateFile(10 * KB, dataFile10KB); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "fileName", fileName }, + { "bucketName", bucketName }, { "objectName", objectName }, { "fileName", fileName } }; try { @@ -1414,8 +1403,7 @@ internal static async Task RemoveObject_Test1(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -1468,8 +1456,7 @@ internal static async Task RemoveObjects_Test2(IMinioClient minio) List objectsList = []; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectNames", "[" + objectName + "0..." + objectName + "50]" }, + { "bucketName", bucketName }, { "objectNames", "[" + objectName + "0..." + objectName + "50]" } }; try { @@ -1528,8 +1515,7 @@ internal static async Task RemoveObjects_Test3(IMinioClient minio) var objectName = GetRandomObjectName(6); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectNames", "[" + objectName + "0..." + objectName + "50]" }, + { "bucketName", bucketName }, { "objectNames", "[" + objectName + "0..." + objectName + "50]" } }; try { @@ -1537,7 +1523,7 @@ internal static async Task RemoveObjects_Test3(IMinioClient minio) var tasks = new Task[count * 2]; List objectsList = []; await Setup_WithLock_Test(minio, bucketName).ConfigureAwait(false); - for (var i = 0; i < count * 2; ) + for (var i = 0; i < count * 2;) { tasks[i++] = PutObject_Task( minio, @@ -1572,9 +1558,7 @@ internal static async Task RemoveObjects_Test3(IMinioClient minio) await foreach ( var item in minio.ListObjectsEnumAsync(listObjectsArgs).ConfigureAwait(false) ) - { objVersions.Add(new Tuple(item.Key, item.VersionId)); - } var removeObjectsArgs = new RemoveObjectsArgs() .WithBucket(bucketName) @@ -1671,7 +1655,7 @@ internal static async Task PresignedPostPolicy_Test1(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "expiresOn", expiresOn.ToString(CultureInfo.InvariantCulture) }, + { "expiresOn", expiresOn.ToString(CultureInfo.InvariantCulture) } }; // File to be uploaded @@ -1754,8 +1738,7 @@ internal static async Task RemoveIncompleteUpload_Test(IMinioClient minio) var contentType = "csv"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -1848,9 +1831,7 @@ internal static async Task SelectObjectContent_Test(IMinioClient minio) var outFileName = "outFileName-SelectObjectContent_Test"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "fileName", outFileName }, + { "bucketName", bucketName }, { "objectName", objectName }, { "fileName", outFileName } }; try { @@ -1877,14 +1858,12 @@ internal static async Task SelectObjectContent_Test(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 selArgs = new SelectObjectContentArgs() .WithBucket(bucketName) @@ -1970,10 +1949,7 @@ internal static async Task BucketEncryptionsAsync_Test1(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { await Setup_Test(minio, bucketName).ConfigureAwait(false); @@ -2158,8 +2134,7 @@ internal static async Task LegalHoldStatusAsync_Test1(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -2315,15 +2290,10 @@ internal static async Task BucketTagsAsync_Test1(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; var tags = new Dictionary(StringComparer.Ordinal) { - { "key1", "value1" }, - { "key2", "value2" }, - { "key3", "value3" }, + { "key1", "value1" }, { "key2", "value2" }, { "key3", "value3" } }; try { @@ -2510,13 +2480,11 @@ internal static async Task ObjectTagsAsync_Test1(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "fileSize", size.ToString(CultureInfo.InvariantCulture) }, + { "fileSize", size.ToString(CultureInfo.InvariantCulture) } }; var tags = new Dictionary(StringComparer.Ordinal) { - { "key1", "value1" }, - { "key2", "value2" }, - { "key3", "value3" }, + { "key1", "value1" }, { "key2", "value2" }, { "key3", "value3" } }; try { @@ -2726,7 +2694,7 @@ internal static async Task ObjectVersioningAsync_Test1(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "fileSize", size.ToString(CultureInfo.InvariantCulture) }, + { "fileSize", size.ToString(CultureInfo.InvariantCulture) } }; try { @@ -2862,10 +2830,7 @@ internal static async Task ObjectLockConfigurationAsync_Test1(IMinioClient minio var startTime = DateTime.Now; var bucketName = GetRandomName(15); var objectName = GetRandomName(10); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; var setLockNotImplemented = false; var getLockNotImplemented = false; @@ -3116,8 +3081,7 @@ internal static async Task ObjectRetentionAsync_Test1(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try @@ -3403,8 +3367,7 @@ internal static async Task GetObjectS3Zip_Test1(IMinioClient minio) var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -3421,7 +3384,7 @@ internal static async Task GetObjectS3Zip_Test1(IMinioClient minio) var extractHeader = new Dictionary(StringComparer.Ordinal) { - { "x-minio-extract", "true" }, + { "x-minio-extract", "true" } }; // GeObject api test @@ -3522,10 +3485,7 @@ internal static async Task ListenNotifications_Test1(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { List received = []; @@ -3617,7 +3577,7 @@ internal static async Task ListenBucketNotificationsAsync_Test1(IMinioClient min { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -3715,7 +3675,7 @@ internal static async Task ListenBucketNotificationsAsync_Test1(IMinioClient min string.Equals( ex.Message, "Listening for bucket notification is specific" - + " only to `minio` server endpoints", + + " only to `minio` server endpoints", StringComparison.OrdinalIgnoreCase ) ) @@ -3735,9 +3695,9 @@ static bool isAWS(string endPoint) } if ( - Environment.GetEnvironmentVariable("AWS_ENDPOINT") is not null - || isAWS(Environment.GetEnvironmentVariable("SERVER_ENDPOINT")) - ) + Environment.GetEnvironmentVariable("AWS_ENDPOINT") is not null + || isAWS(Environment.GetEnvironmentVariable("SERVER_ENDPOINT")) + ) // This is a PASS new MintLogger( nameof(ListenBucketNotificationsAsync_Test1), @@ -3780,9 +3740,7 @@ internal static async Task ListenBucketNotificationsAsync_Test2(IMinioClient min var contentType = "application/json"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "contentType", contentType }, - { "size", "16B" }, + { "bucketName", bucketName }, { "contentType", contentType }, { "size", "16B" } }; try @@ -3892,10 +3850,7 @@ internal static async Task ListenBucketNotificationsAsync_Test3(IMinioClient min var contentType = "application/json"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "contentType", contentType }, - { "suffix", suffix }, - { "size", "16B" }, + { "bucketName", bucketName }, { "contentType", contentType }, { "suffix", suffix }, { "size", "16B" } }; try @@ -4005,8 +3960,7 @@ internal static async Task MakeBucket_Test1(IMinioClient minio) var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "us-east-1" }, + { "bucketName", bucketName }, { "region", "us-east-1" } }; try @@ -4054,8 +4008,7 @@ internal static async Task MakeBucket_Test2(IMinioClient minio, bool aws = false var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "us-east-1" }, + { "bucketName", bucketName }, { "region", "us-east-1" } }; var testType = "Test whether make bucket passes when bucketname has a period."; @@ -4104,8 +4057,7 @@ internal static async Task MakeBucket_Test3(IMinioClient minio, bool aws = false var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "eu-central-1" }, + { "bucketName", bucketName }, { "region", "eu-central-1" } }; try { @@ -4152,8 +4104,7 @@ internal static async Task MakeBucket_Test4(IMinioClient minio, bool aws = false var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "us-west-2" }, + { "bucketName", bucketName }, { "region", "us-west-2" } }; try { @@ -4195,8 +4146,7 @@ internal static async Task MakeBucket_Test5(IMinioClient minio) string bucketName = null; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "us-east-1" }, + { "bucketName", bucketName }, { "region", "us-east-1" } }; try @@ -4240,8 +4190,7 @@ internal static async Task MakeBucketLock_Test1(IMinioClient minio) var rbArgs = new RemoveBucketArgs().WithBucket(bucketName); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "region", "us-east-1" }, + { "bucketName", bucketName }, { "region", "us-east-1" } }; try @@ -4294,7 +4243,7 @@ internal static async Task PutObject_Test1(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "0" }, + { "size", "0" } }; try { @@ -4353,7 +4302,7 @@ internal static async Task PutObject_Test2(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "6MB" }, + { "size", "6MB" } }; try { @@ -4410,7 +4359,7 @@ internal static async Task PutObject_Test3(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "1MB" }, + { "size", "1MB" } }; try @@ -4464,10 +4413,7 @@ internal static async Task PutObject_Test4(IMinioClient minio) var objectName = GetRandomObjectName(10); var fileName = CreateFile(1, dataFile1B); var contentType = "custom/contenttype"; - var metaData = new Dictionary(StringComparer.Ordinal) - { - { "customheader", "minio dotnet" }, - }; + var metaData = new Dictionary(StringComparer.Ordinal) { { "customheader", "minio dotnet" } }; var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName }, @@ -4475,7 +4421,7 @@ internal static async Task PutObject_Test4(IMinioClient minio) { "contentType", contentType }, { "data", "1B" }, { "size", "1B" }, - { "metaData", "customheader:minio-dotnet" }, + { "metaData", "customheader:minio-dotnet" } }; try { @@ -4499,9 +4445,9 @@ internal static async Task PutObject_Test4(IMinioClient minio) Assert.IsTrue(statMeta.ContainsKey("Customheader")); Assert.IsTrue( statObject.MetaData.ContainsKey("Content-Type") - && statObject - .MetaData["Content-Type"] - .Equals("custom/contenttype", StringComparison.OrdinalIgnoreCase) + && statObject + .MetaData["Content-Type"] + .Equals("custom/contenttype", StringComparison.OrdinalIgnoreCase) ); new MintLogger( nameof(PutObject_Test4), @@ -4541,10 +4487,7 @@ internal static async Task PutObject_Test5(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "data", "1B" }, - { "size", "1B" }, + { "bucketName", bucketName }, { "objectName", objectName }, { "data", "1B" }, { "size", "1B" } }; try { @@ -4602,7 +4545,7 @@ internal static async Task PutObject_Test7(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "10KB" }, - { "size", "-1" }, + { "size", "-1" } }; try { @@ -4666,7 +4609,7 @@ internal static async Task PutObject_Test8(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "data", "0B" }, - { "size", "-1" }, + { "size", "-1" } }; try { @@ -4745,7 +4688,7 @@ internal static async Task PutObject_Test9(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "1MB" }, + { "size", "1MB" } }; try { @@ -4827,7 +4770,7 @@ internal static async Task PutObject_Test10(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType }, - { "size", "64MB" }, + { "size", "64MB" } }; try { @@ -4901,7 +4844,7 @@ internal static async Task CopyObject_Test1(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -4987,7 +4930,7 @@ internal static async Task CopyObject_Test2(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", objectSizeStr }, - { "size", objectSizeStr }, + { "size", objectSizeStr } }; try { @@ -5113,7 +5056,7 @@ internal static async Task CopyObject_Test3(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5200,7 +5143,7 @@ internal static async Task CopyObject_Test4(IMinioClient minio) { "objectName", objectName }, { "destBucketName", destBucketName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5286,7 +5229,7 @@ internal static async Task CopyObject_Test5(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "6MB" }, - { "size", "6MB" }, + { "size", "6MB" } }; try { @@ -5382,7 +5325,7 @@ internal static async Task CopyObject_Test6(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5472,7 +5415,7 @@ internal static async Task CopyObject_Test7(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5565,7 +5508,7 @@ internal static async Task CopyObject_Test8(IMinioClient minio) { "destObjectName", destObjectName }, { "data", "1KB" }, { "size", "1KB" }, - { "copyconditions", "x-amz-metadata-directive:REPLACE" }, + { "copyconditions", "x-amz-metadata-directive:REPLACE" } }; try { @@ -5579,10 +5522,7 @@ internal static async Task CopyObject_Test8(IMinioClient minio) .WithStreamData(filestream) .WithObjectSize(filestream.Length) .WithHeaders( - new Dictionary(StringComparer.Ordinal) - { - { "Orig", "orig-val with spaces" }, - } + new Dictionary(StringComparer.Ordinal) { { "Orig", "orig-val with spaces" } } ); _ = await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false); } @@ -5600,7 +5540,7 @@ internal static async Task CopyObject_Test8(IMinioClient minio) { { "Content-Type", "application/css" }, { "Mynewkey", "test test" }, - { "Orig", "orig-valwithoutspaces" }, + { "Orig", "orig-valwithoutspaces" } }; var copySourceObjectArgs = new CopySourceObjectArgs() .WithBucket(bucketName) @@ -5671,7 +5611,7 @@ internal static async Task CopyObject_Test9(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "destBucketName", destBucketName }, - { "destObjectName", destObjectName }, + { "destObjectName", destObjectName } }; try { @@ -5687,10 +5627,7 @@ internal static async Task CopyObject_Test9(IMinioClient minio) .WithObjectSize(filestream.Length); _ = await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false); - var putTags = new Dictionary(StringComparer.Ordinal) - { - { "key1", "PutObjectTags" }, - }; + var putTags = new Dictionary(StringComparer.Ordinal) { { "key1", "PutObjectTags" } }; var setObjectTagsArgs = new SetObjectTagsArgs() .WithBucket(bucketName) .WithObject(objectName) @@ -5698,10 +5635,7 @@ internal static async Task CopyObject_Test9(IMinioClient minio) await minio.SetObjectTagsAsync(setObjectTagsArgs).ConfigureAwait(false); } - var copyTags = new Dictionary(StringComparer.Ordinal) - { - { "key1", "CopyObjectTags" }, - }; + var copyTags = new Dictionary(StringComparer.Ordinal) { { "key1", "CopyObjectTags" } }; var copySourceObjectArgs = new CopySourceObjectArgs() .WithBucket(bucketName) .WithObject(objectName); @@ -5775,7 +5709,7 @@ internal static async Task EncryptedCopyObject_Test1(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5877,7 +5811,7 @@ internal static async Task EncryptedCopyObject_Test2(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -5977,7 +5911,7 @@ internal static async Task EncryptedCopyObject_Test3(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -6063,7 +5997,7 @@ internal static async Task EncryptedCopyObject_Test4(IMinioClient minio) { "destBucketName", destBucketName }, { "destObjectName", destObjectName }, { "data", "1KB" }, - { "size", "1KB" }, + { "size", "1KB" } }; try { @@ -6144,9 +6078,7 @@ internal static async Task GetObject_Test1(IMinioClient minio) var size = 1 * MB; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "contentType", contentType }, + { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType } }; try { @@ -6225,9 +6157,7 @@ internal static async Task GetObject_Test2(IMinioClient minio) var fileName = GetRandomName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "fileName", fileName }, + { "bucketName", bucketName }, { "objectName", objectName }, { "fileName", fileName } }; try { @@ -6330,8 +6260,7 @@ internal static async Task GetObjectNegObjNotFound_Test1andTest2(IMinioClient mi var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -6451,8 +6380,7 @@ internal static async Task GetObjectNegBcktNotFound_Test3(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, + { "bucketName", bucketName }, { "objectName", objectName } }; try { @@ -6496,10 +6424,10 @@ internal static async Task GetObjectNegBcktNotFound_Test3(IMinioClient minio) [SuppressMessage("Design", "MA0051:Method is too long", Justification = "TODO")] internal static async Task GetObject_3_OffsetLength_Tests(IMinioClient minio) - // 3 tests will run to check different values of offset and length parameters - // when GetObject api returns part of the object as defined by the offset - // and length parameters. Tests will be reported as GetObject_Test3, - // GetObject_Test4 and GetObject_Test5. + // 3 tests will run to check different values of offset and length parameters + // when GetObject api returns part of the object as defined by the offset + // and length parameters. Tests will be reported as GetObject_Test3, + // GetObject_Test4 and GetObject_Test5. { var startTime = DateTime.Now; var bucketName = GetRandomName(15); @@ -6510,18 +6438,9 @@ internal static async Task GetObject_3_OffsetLength_Tests(IMinioClient minio) var offsetLengthTests = new Dictionary>(StringComparer.Ordinal) { // list is {offset, length} values - { - "GetObject_Test3", - new List { 14, 20 } - }, - { - "GetObject_Test4", - new List { 30, 0 } - }, - { - "GetObject_Test5", - new List { 0, 25 } - }, + { "GetObject_Test3", new List { 14, 20 } }, + { "GetObject_Test4", new List { 30, 0 } }, + { "GetObject_Test5", new List { 0, 25 } } }; foreach (var test in offsetLengthTests) { @@ -6534,7 +6453,7 @@ internal static async Task GetObject_3_OffsetLength_Tests(IMinioClient minio) { "objectName", objectName }, { "contentType", contentType }, { "offset", offsetToStartFrom.ToString(CultureInfo.InvariantCulture) }, - { "length", lengthToBeRead.ToString(CultureInfo.InvariantCulture) }, + { "length", lengthToBeRead.ToString(CultureInfo.InvariantCulture) } }; string actualContent; try @@ -6685,9 +6604,7 @@ internal static async Task GetObject_AsyncCallback_Test1(IMinioClient minio) var destFileName = GetRandomName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "contentType", contentType }, + { "bucketName", bucketName }, { "objectName", objectName }, { "contentType", contentType } }; try @@ -6774,9 +6691,7 @@ internal static async Task FGetObject_Test1(IMinioClient minio) var outFileName = "outFileName-FGetObject_Test1"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "fileName", outFileName }, + { "bucketName", bucketName }, { "objectName", objectName }, { "fileName", outFileName } }; try { @@ -6838,9 +6753,7 @@ internal static async Task ListObjects_Test1(IMinioClient minio) var objectName = prefix + GetRandomName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "prefix", prefix }, + { "bucketName", bucketName }, { "objectName", objectName }, { "prefix", prefix } }; try { @@ -6894,10 +6807,7 @@ internal static async Task ListObjects_Test2(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { await Setup_Test(minio, bucketName).ConfigureAwait(false); @@ -6943,7 +6853,7 @@ internal static async Task ListObjects_Test3(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "prefix", prefix }, - { "recursive", "true" }, + { "recursive", "true" } }; try { @@ -7000,9 +6910,7 @@ internal static async Task ListObjects_Test4(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectName }, - { "recursive", "false" }, + { "bucketName", bucketName }, { "objectName", objectName }, { "recursive", "false" } }; try { @@ -7060,9 +6968,7 @@ internal static async Task ListObjects_Test5(IMinioClient minio) var numObjects = 100; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectNamePrefix }, - { "recursive", "false" }, + { "bucketName", bucketName }, { "objectName", objectNamePrefix }, { "recursive", "false" } }; List objectNames = []; try @@ -7129,9 +7035,7 @@ internal static async Task ListObjects_Test6(IMinioClient minio) var numObjects = 1015; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectName", objectNamePrefix }, - { "recursive", "false" }, + { "bucketName", bucketName }, { "objectName", objectNamePrefix }, { "recursive", "false" } }; var objectNamesSet = new HashSet(StringComparer.Ordinal); try @@ -7224,7 +7128,7 @@ internal static async Task ListObjects_Test7(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "prefix", prefix }, - { "recursive", "false" }, + { "recursive", "false" } }; try { @@ -7285,7 +7189,7 @@ internal static async Task ListObjects_Test8(IMinioClient minio) { "bucketName", bucketName }, { "objectName", objectName }, { "prefix", prefix }, - { "recursive", "false" }, + { "recursive", "false" } }; try { @@ -7347,7 +7251,7 @@ internal static async Task ListObjectVersions_Test1(IMinioClient minio) { "objectName", objectName }, { "prefix", prefix }, { "recursive", "false" }, - { "versions", "true" }, + { "versions", "true" } }; List> objectVersions = []; try @@ -7481,7 +7385,7 @@ internal static async Task PresignedGetObject_Test1(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) }, + { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) } }; try { @@ -7552,7 +7456,7 @@ internal static async Task PresignedGetObject_Test2(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) }, + { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) } }; try { @@ -7641,7 +7545,7 @@ internal static async Task PresignedGetObject_Test3(IMinioClient minio) "reqParams", "response-content-type:application/json,response-content-disposition:attachment;filename= MyDoc u m e nt.json ;" }, - { "reqDate", reqDate.ToString(CultureInfo.InvariantCulture) }, + { "reqDate", reqDate.ToString(CultureInfo.InvariantCulture) } }; try { @@ -7662,7 +7566,7 @@ internal static async Task PresignedGetObject_Test3(IMinioClient minio) var reqParams = new Dictionary(StringComparer.Ordinal) { ["response-content-type"] = "application/json", - ["response-content-disposition"] = "attachment;filename= MyDoc u m e nt.json ;", + ["response-content-disposition"] = "attachment;filename= MyDoc u m e nt.json ;" }; var preArgs = new PresignedGetObjectArgs() .WithBucket(bucketName) @@ -7759,7 +7663,7 @@ internal static async Task PresignedPutObject_Test1(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) }, + { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) } }; try { @@ -7822,7 +7726,7 @@ internal static async Task PresignedPutObject_Test2(IMinioClient minio) { { "bucketName", bucketName }, { "objectName", objectName }, - { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) }, + { "expiresInt", expiresInt.ToString(CultureInfo.InvariantCulture) } }; try { @@ -7954,9 +7858,7 @@ internal static async Task ListIncompleteUpload_Test2(IMinioClient minio) var contentType = "gzip"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "prefix", prefix }, - { "recursive", "false" }, + { "bucketName", bucketName }, { "prefix", prefix }, { "recursive", "false" } }; try { @@ -8025,9 +7927,7 @@ internal static async Task ListIncompleteUpload_Test3(IMinioClient minio) var contentType = "gzip"; var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "prefix", prefix }, - { "recursive", "true" }, + { "bucketName", bucketName }, { "prefix", prefix }, { "recursive", "true" } }; try { @@ -8103,9 +8003,7 @@ internal static async Task SetBucketPolicy_Test1(IMinioClient minio) var objectName = GetRandomObjectName(10); var args = new Dictionary(StringComparer.Ordinal) { - { "bucketName", bucketName }, - { "objectPrefix", objectName[5..] }, - { "policyType", "readonly" }, + { "bucketName", bucketName }, { "objectPrefix", objectName[5..] }, { "policyType", "readonly" } }; Stream filestream; await Setup_Test(minio, bucketName).ConfigureAwait(false); @@ -8178,10 +8076,7 @@ internal static async Task GetBucketPolicy_Test1(IMinioClient minio) var startTime = DateTime.Now; var bucketName = GetRandomName(15); var objectName = GetRandomObjectName(10); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { await Setup_Test(minio, bucketName).ConfigureAwait(false); @@ -8254,10 +8149,7 @@ internal static async Task BucketLifecycleAsync_Test1(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { await Setup_Test(minio, bucketName).ConfigureAwait(false); @@ -8461,10 +8353,7 @@ internal static async Task BucketLifecycleAsync_Test2(IMinioClient minio) { var startTime = DateTime.Now; var bucketName = GetRandomName(15); - var args = new Dictionary(StringComparer.Ordinal) - { - { "bucketName", bucketName }, - }; + var args = new Dictionary(StringComparer.Ordinal) { { "bucketName", bucketName } }; try { await Setup_Test(minio, bucketName).ConfigureAwait(false); diff --git a/Minio/ApiEndpoints/BucketOperations.cs b/Minio/ApiEndpoints/BucketOperations.cs index 310070cdd..cdc5bcbed 100644 --- a/Minio/ApiEndpoints/BucketOperations.cs +++ b/Minio/ApiEndpoints/BucketOperations.cs @@ -337,7 +337,7 @@ var xHeader in xUserMetadata ContentType = contentType, Expires = expires, UserMetadata = userMetaData, - IsDir = false, + IsDir = false }; }); foreach (var item in items) diff --git a/Minio/ApiEndpoints/IObjectOperations.cs b/Minio/ApiEndpoints/IObjectOperations.cs index 2dc35fdd9..66cb83c14 100644 --- a/Minio/ApiEndpoints/IObjectOperations.cs +++ b/Minio/ApiEndpoints/IObjectOperations.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, * (C) 2017-2021 MinIO, Inc. * @@ -358,4 +358,69 @@ IAsyncEnumerable ListIncompleteUploadsEnumAsync(ListIncompleteUploadsArg /// When object is not found /// When configuration XML provided is invalid Task RemoveObjectTagsAsync(RemoveObjectTagsArgs args, CancellationToken cancellationToken = default); + + /// + /// Upload object part to bucket for particular uploadId + /// + /// + /// PutObjectArgs encapsulates bucket name, object name, upload id, part number, object data(body), + /// Headers, SSE Headers + /// + /// Optional cancellation token to cancel the operation + /// + /// This boolean parameter differentiates single part file upload and + /// multi part file upload as this function is shared by both. + /// + /// + /// When access or secret key is invalid + /// When bucket name is invalid + /// When object name is invalid + /// When bucket is not found + /// The file stream has been disposed + /// The file stream cannot be read from + /// The file stream is currently in a read operation + /// For encrypted PUT operation, Access is denied if the key is wrong + Task PutObjectSinglePartAsync(PutObjectArgs args, CancellationToken cancellationToken = default, + bool singleFile = false); + + + /// + /// Remove object with matching uploadId from bucket + /// + /// RemoveUploadArgs Arguments Object which encapsulates bucket, object names, upload Id + /// Optional cancellation token to cancel the operation + /// + Task RemoveUploadAsync(RemoveUploadArgs args, CancellationToken cancellationToken); + + /// + /// Start a new multi-part upload request + /// + /// + /// NewMultipartUploadPutArgs arguments object encapsulating bucket name, object name, Headers, SSE + /// Headers + /// + /// Optional cancellation token to cancel the operation + /// + /// When access or secret key is invalid + /// When bucket name is invalid + /// When object name is invalid + /// When bucket is not found + /// When object is not found + /// For encrypted copy operation, Access is denied if the key is wrong + Task NewMultipartUploadAsync(NewMultipartUploadPutArgs args, CancellationToken cancellationToken = default); + + /// + /// Internal method to complete multi part upload of object to server. + /// + /// CompleteMultipartUploadArgs Arguments object with bucket name, object name, upload id, Etags + /// Optional cancellation token to cancel the operation + /// + /// When access or secret key is invalid + /// When bucket name is invalid + /// When object name is invalid + /// When bucket is not found + /// When object is not found + /// For encrypted copy operation, Access is denied if the key is wrong + Task CompleteMultipartUploadAsync(CompleteMultipartUploadArgs args, + CancellationToken cancellationToken); } diff --git a/Minio/ApiEndpoints/ObjectOperations.cs b/Minio/ApiEndpoints/ObjectOperations.cs index 0bd6afe23..898678dc7 100644 --- a/Minio/ApiEndpoints/ObjectOperations.cs +++ b/Minio/ApiEndpoints/ObjectOperations.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, * (C) 2017-2021 MinIO, Inc. * @@ -368,9 +368,9 @@ public async Task GetObjectLegalHoldAsync( .ConfigureAwait(false); var legalHoldConfig = new GetLegalHoldResponse(response.StatusCode, response.Content); return legalHoldConfig.CurrentLegalHoldConfiguration?.Status.Equals( - "on", - StringComparison.OrdinalIgnoreCase - ) == true; + "on", + StringComparison.OrdinalIgnoreCase + ) == true; } /// @@ -816,15 +816,15 @@ public async Task CopyObjectAsync( || ( srcByteRangeSize > 0 && args.SourceObject.CopyOperationConditions.byteRangeEnd - >= args.SourceObjectInfo.Size + >= args.SourceObjectInfo.Size ) ) throw new InvalidDataException( $"Specified byte range ({args.SourceObject - .CopyOperationConditions - .byteRangeStart.ToString(CultureInfo.InvariantCulture)}-{args.SourceObject - .CopyOperationConditions.byteRangeEnd.ToString(CultureInfo.InvariantCulture)}) does not fit within source object (size={args.SourceObjectInfo.Size - .ToString(CultureInfo.InvariantCulture)})" + .CopyOperationConditions + .byteRangeStart.ToString(CultureInfo.InvariantCulture)}-{args.SourceObject + .CopyOperationConditions.byteRangeEnd.ToString(CultureInfo.InvariantCulture)}) does not fit within source object (size={args.SourceObjectInfo.Size + .ToString(CultureInfo.InvariantCulture)})" ); if ( @@ -940,41 +940,13 @@ public async Task StatObjectAsync( return statResponse.ObjectInfo; } - /// - /// Get list of multi-part uploads matching particular uploadIdMarker - /// - /// GetMultipartUploadsListArgs Arguments Object which encapsulates bucket name, prefix, recursive - /// Optional cancellation token to cancel the operation - /// - private async Task< - Tuple> - > GetMultipartUploadsListAsync( - GetMultipartUploadsListArgs args, - CancellationToken cancellationToken - ) - { - args?.Validate(); - var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); - using var response = await this.ExecuteTaskAsync( - requestMessageBuilder, - cancellationToken: cancellationToken - ) - .ConfigureAwait(false); - var getUploadResponse = new GetMultipartUploadsListResponse( - response.StatusCode, - response.Content - ); - - return getUploadResponse.UploadResult; - } - /// /// Remove object with matching uploadId from bucket /// /// RemoveUploadArgs Arguments Object which encapsulates bucket, object names, upload Id /// Optional cancellation token to cancel the operation /// - private async Task RemoveUploadAsync(RemoveUploadArgs args, CancellationToken cancellationToken) + public async Task RemoveUploadAsync(RemoveUploadArgs args, CancellationToken cancellationToken) { args?.Validate(); var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); @@ -1006,7 +978,7 @@ private async Task RemoveUploadAsync(RemoveUploadArgs args, CancellationToken ca /// The file stream cannot be read from /// The file stream is currently in a read operation /// For encrypted PUT operation, Access is denied if the key is wrong - private async Task PutObjectSinglePartAsync( + public async Task PutObjectSinglePartAsync( PutObjectArgs args, CancellationToken cancellationToken = default, bool singleFile = false @@ -1057,6 +1029,92 @@ private async Task PutObjectSinglePartAsync( } } + /// + /// Start a new multi-part upload request + /// + /// + /// When access or secret key is invalid + /// When bucket name is invalid + /// When object name is invalid + /// When bucket is not found + /// When object is not found + /// For encrypted copy operation, Access is denied if the key is wrong + public async Task NewMultipartUploadAsync( + NewMultipartUploadPutArgs args, + CancellationToken cancellationToken = default) + { + args?.Validate(); + var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); + using var response = await this.ExecuteTaskAsync( + requestMessageBuilder, + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + var uploadResponse = new NewMultipartUploadResponse(response.StatusCode, response.Content); + return uploadResponse.UploadId; + } + + /// + /// Internal method to complete multi part upload of object to server. + /// + /// CompleteMultipartUploadArgs Arguments object with bucket name, object name, upload id, Etags + /// Optional cancellation token to cancel the operation + /// + /// When access or secret key is invalid + /// When bucket name is invalid + /// When object name is invalid + /// When bucket is not found + /// When object is not found + /// For encrypted copy operation, Access is denied if the key is wrong + public async Task CompleteMultipartUploadAsync( + CompleteMultipartUploadArgs args, + CancellationToken cancellationToken + ) + { + args?.Validate(); + var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); + using var response = await this.ExecuteTaskAsync( + requestMessageBuilder, + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + return new PutObjectResponse( + response.StatusCode, + response.Content, + response.Headers, + -1, + args.ObjectName + ); + } + + /// + /// Get list of multi-part uploads matching particular uploadIdMarker + /// + /// GetMultipartUploadsListArgs Arguments Object which encapsulates bucket name, prefix, recursive + /// Optional cancellation token to cancel the operation + /// + private async Task< + Tuple> + > GetMultipartUploadsListAsync( + GetMultipartUploadsListArgs args, + CancellationToken cancellationToken + ) + { + args?.Validate(); + var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); + using var response = await this.ExecuteTaskAsync( + requestMessageBuilder, + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + var getUploadResponse = new GetMultipartUploadsListResponse( + response.StatusCode, + response.Content + ); + + return getUploadResponse.UploadResult; + } + /// /// Upload object in multiple parts. Private Helper function /// @@ -1108,16 +1166,14 @@ private async Task> PutObjectPartAsync( numPartsUploaded++; totalParts[partNumber - 1] = new Part { - PartNumber = partNumber, - ETag = etag, - Size = (long)expectedReadSize, + PartNumber = partNumber, ETag = etag, Size = (long)expectedReadSize }; - etags[partNumber] = etag; if (!dataToCopy.IsEmpty) progressReport.TotalBytesTransferred += dataToCopy.Length; if (args.ObjectSize != -1) progressReport.Percentage = (int)(100 * partNumber / partCount); args.Progress?.Report(progressReport); + etags[partNumber] = etag; } // This shouldn't happen where stream size is known. @@ -1210,9 +1266,7 @@ private async Task MultipartCopyUploadAsync( totalParts[partNumber - 1] = new Part { - PartNumber = partNumber, - ETag = cpPartResult.ETag, - Size = (long)expectedReadSize, + PartNumber = partNumber, ETag = cpPartResult.ETag, Size = (long)expectedReadSize }; } @@ -1225,37 +1279,17 @@ private async Task MultipartCopyUploadAsync( // Complete multi part upload _ = await CompleteMultipartUploadAsync(completeMultipartUploadArgs, cancellationToken) .ConfigureAwait(false); - } - - /// - /// Start a new multi-part upload request - /// +/* 项目“Minio(netstandard2.0)”的未合并的更改 +在此之前: /// /// NewMultipartUploadPutArgs arguments object encapsulating bucket name, object name, Headers, SSE /// Headers /// /// Optional cancellation token to cancel the operation /// - /// When access or secret key is invalid - /// When bucket name is invalid - /// When object name is invalid - /// When bucket is not found - /// When object is not found - /// For encrypted copy operation, Access is denied if the key is wrong - private async Task NewMultipartUploadAsync( - NewMultipartUploadPutArgs args, - CancellationToken cancellationToken = default - ) - { - args?.Validate(); - var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); - using var response = await this.ExecuteTaskAsync( - requestMessageBuilder, - cancellationToken: cancellationToken - ) - .ConfigureAwait(false); - var uploadResponse = new NewMultipartUploadResponse(response.StatusCode, response.Content); - return uploadResponse.UploadId; +在此之后: + /// +*/ } /// @@ -1273,7 +1307,7 @@ private async Task NewMultipartUploadAsync( /// When bucket is not found /// When object is not found /// For encrypted copy operation, Access is denied if the key is wrong - private async Task NewMultipartUploadAsync( + public async Task NewMultipartUploadAsync( NewMultipartUploadCopyArgs args, CancellationToken cancellationToken = default ) @@ -1327,39 +1361,6 @@ CancellationToken cancellationToken return copyObjectResponse.CopyPartRequestResult; } - /// - /// Internal method to complete multi part upload of object to server. - /// - /// CompleteMultipartUploadArgs Arguments object with bucket name, object name, upload id, Etags - /// Optional cancellation token to cancel the operation - /// - /// When access or secret key is invalid - /// When bucket name is invalid - /// When object name is invalid - /// When bucket is not found - /// When object is not found - /// For encrypted copy operation, Access is denied if the key is wrong - private async Task CompleteMultipartUploadAsync( - CompleteMultipartUploadArgs args, - CancellationToken cancellationToken - ) - { - args?.Validate(); - var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false); - using var response = await this.ExecuteTaskAsync( - requestMessageBuilder, - cancellationToken: cancellationToken - ) - .ConfigureAwait(false); - return new PutObjectResponse( - response.StatusCode, - response.Content, - response.Headers, - -1, - args.ObjectName - ); - } - /// /// Advances in the stream upto currentPartSize or End of Stream /// diff --git a/Minio/Credentials/WebIdentityProvider.cs b/Minio/Credentials/WebIdentityProvider.cs index ed8e05b75..7622dec9d 100644 --- a/Minio/Credentials/WebIdentityProvider.cs +++ b/Minio/Credentials/WebIdentityProvider.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, * (C) 2021 MinIO, Inc. * diff --git a/Minio/DataModel/Args/BucketArgs.cs b/Minio/DataModel/Args/BucketArgs.cs index 3170e6ee6..4b95923a3 100644 --- a/Minio/DataModel/Args/BucketArgs.cs +++ b/Minio/DataModel/Args/BucketArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020, 2021 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,9 +25,9 @@ public abstract class BucketArgs : RequestArgs public bool IsBucketCreationRequest { get; set; } - internal string BucketName { get; set; } + public string BucketName { get; set; } - internal IDictionary Headers { get; set; } = new Dictionary(StringComparer.Ordinal); + public IDictionary Headers { get; set; } = new Dictionary(StringComparer.Ordinal); public T WithBucket(string bucket) { @@ -48,7 +48,7 @@ public virtual T WithHeaders(IDictionary headers) return (T)this; } - internal virtual void Validate() + public virtual void Validate() { Utils.ValidateBucketName(BucketName); } diff --git a/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs b/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs index 67609466b..eb7a0913c 100644 --- a/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs +++ b/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs @@ -19,9 +19,9 @@ namespace Minio.DataModel.Args; -internal class CompleteMultipartUploadArgs : ObjectWriteArgs +public class CompleteMultipartUploadArgs : ObjectWriteArgs { - internal CompleteMultipartUploadArgs() + public CompleteMultipartUploadArgs() { RequestMethod = HttpMethod.Post; } @@ -42,10 +42,10 @@ internal CompleteMultipartUploadArgs(MultipartCopyUploadArgs args) .ToDictionary(item => item.Key, item => item.First().Value, StringComparer.Ordinal); } - internal string UploadId { get; set; } + public string UploadId { get; set; } internal Dictionary ETags { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); if (string.IsNullOrWhiteSpace(UploadId)) @@ -54,13 +54,13 @@ internal override void Validate() throw new InvalidOperationException(nameof(ETags) + " dictionary cannot be empty."); } - internal CompleteMultipartUploadArgs WithUploadId(string uploadId) + public CompleteMultipartUploadArgs WithUploadId(string uploadId) { UploadId = uploadId; return this; } - internal CompleteMultipartUploadArgs WithETags(IDictionary etags) + public CompleteMultipartUploadArgs WithETags(IDictionary etags) { if (etags?.Count > 0) ETags = new Dictionary(etags); diff --git a/Minio/DataModel/Args/CopyObjectArgs.cs b/Minio/DataModel/Args/CopyObjectArgs.cs index 7b266b54d..919ed2a1d 100644 --- a/Minio/DataModel/Args/CopyObjectArgs.cs +++ b/Minio/DataModel/Args/CopyObjectArgs.cs @@ -41,37 +41,37 @@ public CopyObjectArgs() internal DateTime RetentionUntilDate { get; set; } internal bool ObjectLockSet { get; set; } - internal override void Validate() + public override void Validate() { Utils.ValidateBucketName(BucketName); if (SourceObject is null) throw new InvalidOperationException( nameof(SourceObject) - + " has not been assigned. Please use " - + nameof(WithCopyObjectSource) + + " has not been assigned. Please use " + + nameof(WithCopyObjectSource) ); if (SourceObjectInfo is null) throw new InvalidOperationException( "StatObject result for the copy source object needed to continue copy operation. Use " - + nameof(WithCopyObjectSourceStats) - + " to initialize StatObject result." + + nameof(WithCopyObjectSourceStats) + + " to initialize StatObject result." ); if (!string.IsNullOrEmpty(NotMatchETag) && !string.IsNullOrEmpty(MatchETag)) throw new InvalidOperationException( "Invalid to set both Etag match conditions " - + nameof(NotMatchETag) - + " and " - + nameof(MatchETag) + + nameof(NotMatchETag) + + " and " + + nameof(MatchETag) ); if (!ModifiedSince.Equals(default) && !UnModifiedSince.Equals(default)) throw new InvalidOperationException( "Invalid to set both modified date match conditions " - + nameof(ModifiedSince) - + " and " - + nameof(UnModifiedSince) + + nameof(ModifiedSince) + + " and " + + nameof(UnModifiedSince) ); Populate(); diff --git a/Minio/DataModel/Args/CopyObjectRequestArgs.cs b/Minio/DataModel/Args/CopyObjectRequestArgs.cs index cdf45a54f..9f4736839 100644 --- a/Minio/DataModel/Args/CopyObjectRequestArgs.cs +++ b/Minio/DataModel/Args/CopyObjectRequestArgs.cs @@ -170,7 +170,7 @@ public CopyObjectRequestArgs WithObjectLockRetentionDate(DateTime untilDate) return this; } - internal override void Validate() + public override void Validate() { Utils.ValidateBucketName(BucketName); //Object name can be same as that of source. if (SourceObject is null) throw new InvalidOperationException(nameof(SourceObject) + " has not been assigned."); diff --git a/Minio/DataModel/Args/EncryptionArgs.cs b/Minio/DataModel/Args/EncryptionArgs.cs index fb6831550..ea8daaff8 100644 --- a/Minio/DataModel/Args/EncryptionArgs.cs +++ b/Minio/DataModel/Args/EncryptionArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2021 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,7 @@ namespace Minio.DataModel.Args; public abstract class EncryptionArgs : ObjectArgs where T : EncryptionArgs { - internal IServerSideEncryption SSE { get; set; } + public IServerSideEncryption SSE { get; set; } public T WithServerSideEncryption(IServerSideEncryption sse) { diff --git a/Minio/DataModel/Args/GetObjectArgs.cs b/Minio/DataModel/Args/GetObjectArgs.cs index c7204ebf7..e564b1206 100644 --- a/Minio/DataModel/Args/GetObjectArgs.cs +++ b/Minio/DataModel/Args/GetObjectArgs.cs @@ -34,7 +34,7 @@ public GetObjectArgs() internal string FileName { get; private set; } internal bool OffsetLengthSet { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); if (CallBack is null && string.IsNullOrEmpty(FileName)) diff --git a/Minio/DataModel/Args/MultipartCopyUploadArgs.cs b/Minio/DataModel/Args/MultipartCopyUploadArgs.cs index edb77bce8..d10d8fe4a 100644 --- a/Minio/DataModel/Args/MultipartCopyUploadArgs.cs +++ b/Minio/DataModel/Args/MultipartCopyUploadArgs.cs @@ -28,13 +28,13 @@ internal MultipartCopyUploadArgs(CopyObjectArgs args) { var message = args is null ? "The constructor of " - + nameof(CopyObjectRequestArgs) - + "initialized with arguments of CopyObjectArgs null." + + nameof(CopyObjectRequestArgs) + + "initialized with arguments of CopyObjectArgs null." : "The constructor of " - + nameof(CopyObjectRequestArgs) - + "initialized with arguments of CopyObjectArgs type but with " - + nameof(args.SourceObject) - + " not initialized."; + + nameof(CopyObjectRequestArgs) + + "initialized with arguments of CopyObjectArgs type but with " + + nameof(args.SourceObject) + + " not initialized."; throw new InvalidOperationException(message); } @@ -49,7 +49,7 @@ internal MultipartCopyUploadArgs(CopyObjectArgs args) MatchETag = args.SourceObject.MatchETag, ModifiedSince = args.SourceObject.ModifiedSince, NotMatchETag = args.SourceObject.NotMatchETag, - UnModifiedSince = args.SourceObject.UnModifiedSince, + UnModifiedSince = args.SourceObject.UnModifiedSince }; // Destination part. diff --git a/Minio/DataModel/Args/NewMultipartUploadArgs.cs b/Minio/DataModel/Args/NewMultipartUploadArgs.cs index 7f12159db..82d187aff 100644 --- a/Minio/DataModel/Args/NewMultipartUploadArgs.cs +++ b/Minio/DataModel/Args/NewMultipartUploadArgs.cs @@ -19,7 +19,7 @@ namespace Minio.DataModel.Args; -internal class NewMultipartUploadArgs : ObjectWriteArgs +public class NewMultipartUploadArgs : ObjectWriteArgs where T : NewMultipartUploadArgs { internal NewMultipartUploadArgs() diff --git a/Minio/DataModel/Args/NewMultipartUploadCopyArgs.cs b/Minio/DataModel/Args/NewMultipartUploadCopyArgs.cs index 29ec7b40c..4b2d9ea9d 100644 --- a/Minio/DataModel/Args/NewMultipartUploadCopyArgs.cs +++ b/Minio/DataModel/Args/NewMultipartUploadCopyArgs.cs @@ -19,7 +19,7 @@ namespace Minio.DataModel.Args; -internal class NewMultipartUploadCopyArgs : NewMultipartUploadArgs +public class NewMultipartUploadCopyArgs : NewMultipartUploadArgs { internal bool ReplaceMetadataDirective { get; set; } internal bool ReplaceTagsDirective { get; set; } @@ -27,15 +27,15 @@ internal class NewMultipartUploadCopyArgs : NewMultipartUploadArgs +public class NewMultipartUploadPutArgs : NewMultipartUploadArgs { internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { diff --git a/Minio/DataModel/Args/ObjectArgs.cs b/Minio/DataModel/Args/ObjectArgs.cs index c09bdc671..695253380 100644 --- a/Minio/DataModel/Args/ObjectArgs.cs +++ b/Minio/DataModel/Args/ObjectArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,8 +23,8 @@ public abstract class ObjectArgs : BucketArgs { protected const string S3ZipExtractKey = "X-Minio-Extract"; - internal string ObjectName { get; set; } - internal ReadOnlyMemory RequestBody { get; set; } + public string ObjectName { get; set; } + public ReadOnlyMemory RequestBody { get; set; } public T WithObject(string obj) { @@ -38,7 +38,7 @@ public T WithRequestBody(ReadOnlyMemory data) return (T)this; } - internal override void Validate() + public override void Validate() { base.Validate(); Utils.ValidateObjectName(ObjectName); diff --git a/Minio/DataModel/Args/ObjectConditionalQueryArgs.cs b/Minio/DataModel/Args/ObjectConditionalQueryArgs.cs index ea17fdf8b..caf026d94 100644 --- a/Minio/DataModel/Args/ObjectConditionalQueryArgs.cs +++ b/Minio/DataModel/Args/ObjectConditionalQueryArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020, 2021 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,12 @@ namespace Minio.DataModel.Args; public abstract class ObjectConditionalQueryArgs : ObjectVersionArgs where T : ObjectConditionalQueryArgs { - internal string MatchETag { get; set; } - internal string NotMatchETag { get; set; } - internal DateTime ModifiedSince { get; set; } - internal DateTime UnModifiedSince { get; set; } + public string MatchETag { get; set; } + public string NotMatchETag { get; set; } + public DateTime ModifiedSince { get; set; } + public DateTime UnModifiedSince { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); if (!string.IsNullOrEmpty(MatchETag) && !string.IsNullOrEmpty(NotMatchETag)) diff --git a/Minio/DataModel/Args/ObjectVersionArgs.cs b/Minio/DataModel/Args/ObjectVersionArgs.cs index da1ee425b..271bb6897 100644 --- a/Minio/DataModel/Args/ObjectVersionArgs.cs +++ b/Minio/DataModel/Args/ObjectVersionArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,7 @@ namespace Minio.DataModel.Args; public abstract class ObjectVersionArgs : EncryptionArgs where T : ObjectVersionArgs { - internal string VersionId { get; set; } + public string VersionId { get; set; } public T WithVersionId(string vid) { diff --git a/Minio/DataModel/Args/ObjectWriteArgs.cs b/Minio/DataModel/Args/ObjectWriteArgs.cs index da8ce8a46..0f277a5b2 100644 --- a/Minio/DataModel/Args/ObjectWriteArgs.cs +++ b/Minio/DataModel/Args/ObjectWriteArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020, 2021 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,10 @@ namespace Minio.DataModel.Args; public abstract class ObjectWriteArgs : ObjectConditionalQueryArgs where T : ObjectWriteArgs { - internal Tagging ObjectTags { get; set; } - internal ObjectRetentionConfiguration Retention { get; set; } - internal bool? LegalHoldEnabled { get; set; } - internal string ContentType { get; set; } + public Tagging ObjectTags { get; set; } + public ObjectRetentionConfiguration Retention { get; set; } + public bool? LegalHoldEnabled { get; set; } + public string ContentType { get; set; } public T WithTagging(Tagging tagging) { diff --git a/Minio/DataModel/Args/PresignedGetObjectArgs.cs b/Minio/DataModel/Args/PresignedGetObjectArgs.cs index b993a0425..e34c6fdca 100644 --- a/Minio/DataModel/Args/PresignedGetObjectArgs.cs +++ b/Minio/DataModel/Args/PresignedGetObjectArgs.cs @@ -29,7 +29,7 @@ public PresignedGetObjectArgs() internal int Expiry { get; set; } internal DateTime? RequestDate { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); if (!Utils.IsValidExpiry(Expiry)) diff --git a/Minio/DataModel/Args/PutObjectArgs.cs b/Minio/DataModel/Args/PutObjectArgs.cs index 8b416496e..59bfc11bc 100644 --- a/Minio/DataModel/Args/PutObjectArgs.cs +++ b/Minio/DataModel/Args/PutObjectArgs.cs @@ -30,7 +30,7 @@ public PutObjectArgs() ContentType = "application/octet-stream"; } - internal PutObjectArgs(PutObjectPartArgs args) + public PutObjectArgs(PutObjectPartArgs args) { RequestMethod = HttpMethod.Put; BucketName = args.BucketName; @@ -44,14 +44,14 @@ internal PutObjectArgs(PutObjectPartArgs args) UploadId = args.UploadId; } - internal string UploadId { get; private set; } - internal int PartNumber { get; set; } - internal string FileName { get; set; } - internal long ObjectSize { get; set; } - internal Stream ObjectStreamData { get; set; } - internal IProgress Progress { get; set; } + public string UploadId { get; private set; } + public int PartNumber { get; set; } + public string FileName { get; set; } + public long ObjectSize { get; set; } = -1; + public Stream ObjectStreamData { get; set; } + public IProgress Progress { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); // Check atleast one of filename or stream are initialized @@ -67,6 +67,9 @@ internal override void Validate() " should be set."); if (!string.IsNullOrWhiteSpace(FileName)) Utils.ValidateFile(FileName); + // Check object size when using stream data + if (ObjectStreamData is not null && ObjectSize == -1) + throw new InvalidOperationException($"{nameof(ObjectSize)} must be set"); Populate(); } @@ -152,13 +155,13 @@ public override PutObjectArgs WithHeaders(IDictionary headers) return this; } - internal PutObjectArgs WithUploadId(string id = null) + public PutObjectArgs WithUploadId(string id = null) { UploadId = id; return this; } - internal PutObjectArgs WithPartNumber(int num) + public PutObjectArgs WithPartNumber(int num) { PartNumber = num; return this; diff --git a/Minio/DataModel/Args/PutObjectPartArgs.cs b/Minio/DataModel/Args/PutObjectPartArgs.cs index 653cfc7c0..cd7acf104 100644 --- a/Minio/DataModel/Args/PutObjectPartArgs.cs +++ b/Minio/DataModel/Args/PutObjectPartArgs.cs @@ -18,14 +18,14 @@ namespace Minio.DataModel.Args; -internal class PutObjectPartArgs : PutObjectArgs +public class PutObjectPartArgs : PutObjectArgs { public PutObjectPartArgs() { RequestMethod = HttpMethod.Put; } - internal override void Validate() + public override void Validate() { base.Validate(); if (string.IsNullOrWhiteSpace(UploadId)) diff --git a/Minio/DataModel/Args/RemoveObjectsArgs.cs b/Minio/DataModel/Args/RemoveObjectsArgs.cs index 688e23262..1f149bf33 100644 --- a/Minio/DataModel/Args/RemoveObjectsArgs.cs +++ b/Minio/DataModel/Args/RemoveObjectsArgs.cs @@ -55,8 +55,8 @@ IList>> objectsVersionsList throw new ArgumentNullException(nameof(objectsVersionsList)); foreach (var objVersions in objectsVersionsList) - foreach (var vid in objVersions.Item2) - ObjectNamesVersions.Add(new Tuple(objVersions.Item1, vid)); + foreach (var vid in objVersions.Item2) + ObjectNamesVersions.Add(new Tuple(objVersions.Item1, vid)); return this; } @@ -73,18 +73,18 @@ public RemoveObjectsArgs WithObjects(IList names) return this; } - internal override void Validate() + public override void Validate() { // Skip object name validation. Utils.ValidateBucketName(BucketName); if (!string.IsNullOrEmpty(ObjectName)) throw new InvalidOperationException( nameof(ObjectName) - + " is set. Please use " - + nameof(WithObjects) - + "or " - + nameof(WithObjectsVersions) - + " method to set objects to be deleted." + + " is set. Please use " + + nameof(WithObjects) + + "or " + + nameof(WithObjectsVersions) + + " method to set objects to be deleted." ); if ( @@ -93,9 +93,9 @@ internal override void Validate() ) throw new InvalidOperationException( "Please assign list of object names or object names and version IDs to remove using method(s) " - + nameof(WithObjects) - + " " - + nameof(WithObjectsVersions) + + nameof(WithObjects) + + " " + + nameof(WithObjectsVersions) ); } diff --git a/Minio/DataModel/Args/RemoveUploadArgs.cs b/Minio/DataModel/Args/RemoveUploadArgs.cs index 60a4a1035..b8b5879aa 100644 --- a/Minio/DataModel/Args/RemoveUploadArgs.cs +++ b/Minio/DataModel/Args/RemoveUploadArgs.cs @@ -31,7 +31,7 @@ public RemoveUploadArgs WithUploadId(string id) return this; } - internal override void Validate() + public override void Validate() { base.Validate(); if (string.IsNullOrEmpty(UploadId)) diff --git a/Minio/DataModel/Args/RequestArgs.cs b/Minio/DataModel/Args/RequestArgs.cs index 3dbe3764a..65ac9171a 100644 --- a/Minio/DataModel/Args/RequestArgs.cs +++ b/Minio/DataModel/Args/RequestArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ public abstract class RequestArgs // RequestMethod will be the HTTP Method for request variable, // which is of type HttpRequestMessage. // Will be one of the types: - HEAD, GET, PUT, DELETE. etc. - internal HttpMethod RequestMethod { get; set; } + public HttpMethod RequestMethod { get; set; } internal virtual HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { diff --git a/Minio/DataModel/Args/SelectObjectContentArgs.cs b/Minio/DataModel/Args/SelectObjectContentArgs.cs index 660b8d583..85eb62bcb 100644 --- a/Minio/DataModel/Args/SelectObjectContentArgs.cs +++ b/Minio/DataModel/Args/SelectObjectContentArgs.cs @@ -30,7 +30,7 @@ public SelectObjectContentArgs() selectOptions = new SelectObjectOptions(); } - internal override void Validate() + public override void Validate() { base.Validate(); if (string.IsNullOrEmpty(selectOptions.Expression)) diff --git a/Minio/DataModel/Args/SetBucketLifecycleArgs.cs b/Minio/DataModel/Args/SetBucketLifecycleArgs.cs index 086f5f238..916333db7 100644 --- a/Minio/DataModel/Args/SetBucketLifecycleArgs.cs +++ b/Minio/DataModel/Args/SetBucketLifecycleArgs.cs @@ -49,7 +49,7 @@ internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuild return requestMessageBuilder; } - internal override void Validate() + public override void Validate() { base.Validate(); if (BucketLifecycle is null || BucketLifecycle.Rules.Count == 0) diff --git a/Minio/DataModel/Args/SetBucketTagsArgs.cs b/Minio/DataModel/Args/SetBucketTagsArgs.cs index 8d10451e9..972be5d47 100644 --- a/Minio/DataModel/Args/SetBucketTagsArgs.cs +++ b/Minio/DataModel/Args/SetBucketTagsArgs.cs @@ -51,7 +51,7 @@ internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuild return requestMessageBuilder; } - internal override void Validate() + public override void Validate() { base.Validate(); if (BucketTags is null || BucketTags.Tags.Count == 0) diff --git a/Minio/DataModel/Args/SetObjectLockConfigurationArgs.cs b/Minio/DataModel/Args/SetObjectLockConfigurationArgs.cs index bfe40bc7a..1ed7a2615 100644 --- a/Minio/DataModel/Args/SetObjectLockConfigurationArgs.cs +++ b/Minio/DataModel/Args/SetObjectLockConfigurationArgs.cs @@ -35,7 +35,7 @@ public SetObjectLockConfigurationArgs WithLockConfiguration(ObjectLockConfigurat return this; } - internal override void Validate() + public override void Validate() { base.Validate(); if (LockConfiguration is null) diff --git a/Minio/DataModel/Args/SetObjectRetentionArgs.cs b/Minio/DataModel/Args/SetObjectRetentionArgs.cs index 75af87b33..2364a35d9 100644 --- a/Minio/DataModel/Args/SetObjectRetentionArgs.cs +++ b/Minio/DataModel/Args/SetObjectRetentionArgs.cs @@ -33,7 +33,7 @@ public SetObjectRetentionArgs() internal ObjectRetentionMode Mode { get; set; } internal DateTime RetentionUntilDate { get; set; } - internal override void Validate() + public override void Validate() { base.Validate(); if (RetentionUntilDate.Equals(default)) diff --git a/Minio/DataModel/Args/SetObjectTagsArgs.cs b/Minio/DataModel/Args/SetObjectTagsArgs.cs index 093ad6fc9..3f848e6a7 100644 --- a/Minio/DataModel/Args/SetObjectTagsArgs.cs +++ b/Minio/DataModel/Args/SetObjectTagsArgs.cs @@ -46,7 +46,7 @@ internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuild return requestMessageBuilder; } - internal override void Validate() + public override void Validate() { base.Validate(); if (ObjectTags is null || ObjectTags.Tags.Count == 0) diff --git a/Minio/DataModel/Args/SetVersioningArgs.cs b/Minio/DataModel/Args/SetVersioningArgs.cs index 0da808607..846485e3b 100644 --- a/Minio/DataModel/Args/SetVersioningArgs.cs +++ b/Minio/DataModel/Args/SetVersioningArgs.cs @@ -1,4 +1,4 @@ -/* +/* * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +30,7 @@ public SetVersioningArgs() CurrentVersioningStatus = VersioningStatus.Off; } - internal override void Validate() + public override void Validate() { Utils.ValidateBucketName(BucketName); if (CurrentVersioningStatus > VersioningStatus.Suspended) diff --git a/Minio/DataModel/Args/StatObjectArgs.cs b/Minio/DataModel/Args/StatObjectArgs.cs index d92876cfb..e59951b85 100644 --- a/Minio/DataModel/Args/StatObjectArgs.cs +++ b/Minio/DataModel/Args/StatObjectArgs.cs @@ -39,7 +39,7 @@ internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuild return requestMessageBuilder; } - internal override void Validate() + public override void Validate() { base.Validate(); if (!string.IsNullOrEmpty(NotMatchETag) && !string.IsNullOrEmpty(MatchETag)) diff --git a/Minio/DataModel/DeleteObjectsRequest.cs b/Minio/DataModel/DeleteObjectsRequest.cs index 771acfa54..7cdb9dfd5 100644 --- a/Minio/DataModel/DeleteObjectsRequest.cs +++ b/Minio/DataModel/DeleteObjectsRequest.cs @@ -14,7 +14,6 @@ * limitations under the License. */ -using System.Collections.ObjectModel; using System.Xml.Serialization; namespace Minio.DataModel; diff --git a/Minio/DataModel/ILM/AndOperator.cs b/Minio/DataModel/ILM/AndOperator.cs index 3e7fbec3b..492206f8a 100644 --- a/Minio/DataModel/ILM/AndOperator.cs +++ b/Minio/DataModel/ILM/AndOperator.cs @@ -52,8 +52,7 @@ public AndOperator(string prefix, IDictionary tags) Tags.Add(new Tag(item.Key, item.Value)); } - [XmlElement("Prefix")] - public string Prefix { get; set; } + [XmlElement("Prefix")] public string Prefix { get; set; } [XmlElement(ElementName = "Tag", IsNullable = false)] public Collection Tags { get; set; } diff --git a/Minio/DataModel/PostPolicy.cs b/Minio/DataModel/PostPolicy.cs index 1ceddb565..be886c752 100644 --- a/Minio/DataModel/PostPolicy.cs +++ b/Minio/DataModel/PostPolicy.cs @@ -158,7 +158,7 @@ public void SetContentLength(long contentLength) "content-length-range", contentLength.ToString(CultureInfo.InvariantCulture), contentLength.ToString(CultureInfo.InvariantCulture) - ), + ) } ); } @@ -186,7 +186,7 @@ public void SetContentRange(long startRange, long endRange) "content-length-range", startRange.ToString(CultureInfo.InvariantCulture), endRange.ToString(CultureInfo.InvariantCulture) - ), + ) } ); } @@ -295,12 +295,12 @@ private ReadOnlySpan MarshalJSON() foreach (var condition in Conditions) policyList.Add( "[\"" - + condition[0].Item1 - + "\",\"" - + condition[0].Item2 - + "\",\"" - + condition[0].Item3 - + "\"]" + + condition[0].Item1 + + "\",\"" + + condition[0].Item2 + + "\",\"" + + condition[0].Item3 + + "\"]" ); // expiration and policies will never be empty because of checks at PresignedPostPolicy() diff --git a/Minio/DataModel/Response/GetMultipartUploadsListResponse.cs b/Minio/DataModel/Response/GetMultipartUploadsListResponse.cs index d5a34c3d4..8fe46a035 100644 --- a/Minio/DataModel/Response/GetMultipartUploadsListResponse.cs +++ b/Minio/DataModel/Response/GetMultipartUploadsListResponse.cs @@ -42,7 +42,7 @@ from c in root.Root.Descendants(ns + "Upload") { Key = c.Element(ns + "Key").Value, UploadId = c.Element(ns + "UploadId").Value, - Initiated = c.Element(ns + "Initiated").Value, + Initiated = c.Element(ns + "Initiated").Value }; UploadResult = new Tuple>( uploadsResult, diff --git a/Minio/HttpRequestMessageBuilder.cs b/Minio/HttpRequestMessageBuilder.cs index 93419a0c7..1fcd498eb 100644 --- a/Minio/HttpRequestMessageBuilder.cs +++ b/Minio/HttpRequestMessageBuilder.cs @@ -31,10 +31,14 @@ internal HttpRequestMessageBuilder(Uri requestUri, HttpMethod method) } public HttpRequestMessageBuilder(HttpMethod method, Uri host, string path) - : this(method, new UriBuilder(host) { Path = host.AbsolutePath + path }.Uri) { } + : this(method, new UriBuilder(host) { Path = host.AbsolutePath + path }.Uri) + { + } public HttpRequestMessageBuilder(HttpMethod method, string requestUrl) - : this(method, new Uri(requestUrl)) { } + : this(method, new Uri(requestUrl)) + { + } public HttpRequestMessageBuilder(HttpMethod method, Uri requestUri) { diff --git a/Minio/MinioClient.cs b/Minio/MinioClient.cs index 2e541fb61..23f8a5eb6 100644 --- a/Minio/MinioClient.cs +++ b/Minio/MinioClient.cs @@ -130,11 +130,8 @@ private static void ParseErrorNoContent(ResponseResult response) throw new ArgumentNullException(nameof(response)); var statusCodeStrs = new[] { - nameof(HttpStatusCode.Forbidden), - nameof(HttpStatusCode.BadRequest), - nameof(HttpStatusCode.NotFound), - nameof(HttpStatusCode.MethodNotAllowed), - nameof(HttpStatusCode.NotImplemented), + nameof(HttpStatusCode.Forbidden), nameof(HttpStatusCode.BadRequest), nameof(HttpStatusCode.NotFound), + nameof(HttpStatusCode.MethodNotAllowed), nameof(HttpStatusCode.NotImplemented) }; if ( @@ -174,9 +171,9 @@ private static void ParseErrorNoContent(ResponseResult response) if (response.ErrorMessage.Contains("No route to host", StringComparison.OrdinalIgnoreCase)) throw new ConnectionException( "Connection error:" - + "Name or service not known (" - + response.Request.RequestUri.Authority - + ")" + + "Name or service not known (" + + response.Request.RequestUri.Authority + + ")" ); if ( @@ -350,13 +347,11 @@ private static void ParseErrorFromContent(ResponseResult response) || errResponse.Code.Equals("InvalidAccessKeyId", StringComparison.OrdinalIgnoreCase) ) ) - { throw new AuthorizationException( errResponse.Resource, errResponse.BucketName, errResponse.Message ); - } // Handle XML response for Bucket Policy not found case if ( @@ -374,9 +369,7 @@ private static void ParseErrorFromContent(ResponseResult response) StringComparison.OrdinalIgnoreCase ) ) - { throw new ErrorResponseException(errResponse, response) { XmlError = response.Content }; - } if ( response @@ -384,9 +377,7 @@ private static void ParseErrorFromContent(ResponseResult response) .Contains(nameof(HttpStatusCode.NotFound), StringComparison.OrdinalIgnoreCase) && string.Equals(errResponse.Code, "NoSuchBucket", StringComparison.OrdinalIgnoreCase) ) - { throw new BucketNotFoundException(errResponse.BucketName); - } if ( response @@ -394,9 +385,7 @@ private static void ParseErrorFromContent(ResponseResult response) .Contains(nameof(HttpStatusCode.NotFound), StringComparison.OrdinalIgnoreCase) && string.Equals(errResponse.Code, "NoSuchKey", StringComparison.OrdinalIgnoreCase) ) - { throw new ObjectNotFoundException(errResponse.BucketName); - } if ( response @@ -487,16 +476,12 @@ private static void ParseErrorFromContent(ResponseResult response) ) throw new PreconditionFailedException( "At least one of the pre-conditions you " - + "specified did not hold for object: \"" - + errResponse.Resource - + "\"" + + "specified did not hold for object: \"" + + errResponse.Resource + + "\"" ); - throw new UnexpectedMinioException(errResponse.Message) - { - Response = errResponse, - XmlError = response.Content, - }; + throw new UnexpectedMinioException(errResponse.Message) { Response = errResponse, XmlError = response.Content }; } protected virtual void Dispose(bool disposing)