Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into minio-dotnet-bucket…
Browse files Browse the repository at this point in the history
…encryption
  • Loading branch information
BigUstad committed Dec 3, 2020
2 parents b8c8536 + 1982b4b commit 67a519a
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 184 deletions.
40 changes: 24 additions & 16 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,9 @@ catch (MinioException e)


<a name="listIncompleteUploads"></a>
### ListIncompleteUploads(string bucketName, string prefix, bool recursive)
### ListIncompleteUploads(ListIncompleteUploadsArgs args)

`IObservable<Upload> ListIncompleteUploads(string bucketName, string prefix, bool recursive, CancellationToken cancellationToken = default(CancellationToken))`
`IObservable<Upload> ListIncompleteUploads(ListIncompleteUploadsArgs args, CancellationToken cancellationToken = default(CancellationToken))`

Lists partially uploaded objects in a bucket.

Expand All @@ -756,9 +756,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Name of the bucket |
| ``prefix`` | _string_ | Prefix string. List objects whose name starts with ``prefix`` |
| ``recursive`` | _bool_ | when false, emulates a directory structure where each listing returned is either a full object or part of the object's key up to the first '/'. All objects with the same prefix up to the first '/' will be merged into one entry |
| ``args`` | _ListIncompleteUploadsArgs_ | ListIncompleteUploadsArgs object - encapsulates bucket name, prefix, show recursively. |
| ``cancellationToken``| _System.Threading.CancellationToken_ | Optional parameter. Defaults to default(CancellationToken) |


Expand All @@ -778,7 +776,11 @@ try
if (found)
{
// List all incomplete multipart upload of objects in 'mybucket'
IObservable<Upload> observable = minioClient.ListIncompleteUploads("mybucket", "prefix", true);
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
.WithBucket("mybucket")
.WithPrefix("prefix")
.WithRecursive(true);
IObservable<Upload> observable = minioClient.ListIncompleteUploads(listArgs);
IDisposable subscription = observable.Subscribe(
item => Console.WriteLine("OnNext: {0}", item.Key),
ex => Console.WriteLine("OnError: {0}", ex.Message),
Expand Down Expand Up @@ -1707,9 +1709,9 @@ catch(MinioException e)
```

<a name="presignedPutObject"></a>
### PresignedPutObjectAsync(string bucketName, string objectName, int expiresInt)
### PresignedPutObjectAsync(PresignedPutObjectArgs args)

`Task<string> PresignedPutObjectAsync(string bucketName, string objectName, int expiresInt)`
`Task<string> PresignedPutObjectAsync(PresignedPutObjectArgs args)`

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

Expand All @@ -1718,9 +1720,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Name of the bucket |
| ``objectName`` | _string_ | Object name in the bucket |
| ``expiresInt`` | _int_ | Expiry in seconds. Default expiry is set to 7 days. |
| ``args`` | _PresignedPutObjectArgs_ | PresignedPutObjectArgs arguments object with bucket, object names & expiry |

| Return Type | Exceptions |
|:--- |:--- |
Expand All @@ -1736,7 +1736,11 @@ __Example__
```cs
try
{
String url = await minioClient.PresignedPutObjectAsync("mybucket", "myobject", 60 * 60 * 24);
PresignedPutObjectArgs args = PresignedPutObjectArgs()
.WithBucket("mybucket")
.WithObject("myobject")
.WithExpiry(60 * 60 * 24);
String url = await minioClient.PresignedPutObjectAsync(args);
Console.WriteLine(url);
}
catch(MinioException e)
Expand All @@ -1746,9 +1750,9 @@ catch(MinioException e)
```

<a name="presignedPostPolicy"></a>
### PresignedPostPolicy(PostPolicy policy)
### PresignedPostPolicy(PresignedPostPolicyArgs args)

`Task<Dictionary<string, string>> PresignedPostPolicyAsync(PostPolicy policy)`
`Task<Dictionary<string, string>> PresignedPostPolicyAsync(PresignedPostPolicyArgs args)`

Allows setting policy conditions to a presigned URL for POST operations. Policies such as bucket name to receive object uploads, key name prefixes, expiry policy may be set.

Expand All @@ -1757,7 +1761,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``PostPolicy`` | _PostPolicy_ | Post policy of an object. |
| ``args`` | _PresignedPostPolicyArgs_ | PresignedPostPolicyArgs Arguments object includes bucket, object names & Post policy of an object. |


| Return Type | Exceptions |
Expand All @@ -1782,8 +1786,12 @@ try
policy.SetExpires(expiration.AddDays(10));
policy.SetKey("my-objectname");
policy.SetBucket("my-bucketname");
PresignedPostPolicyArgs args = PresignedPostPolicyArgs()
.WithBucket("my-bucketname")
.WithObject("my-objectname")
.WithPolicy(policy);

Dictionary<string, string> formData = minioClient.Api.PresignedPostPolicy(policy);
Dictionary<string, string> formData = minioClient.Api.PresignedPostPolicy(args);
string curlCommand = "curl ";
foreach (KeyValuePair<string, string> pair in formData)
{
Expand Down
6 changes: 5 additions & 1 deletion Minio.Examples/Cases/ListIncompleteUploads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public static void Run(MinioClient minio,
{
Console.WriteLine("Running example for API: ListIncompleteUploads");

IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName, prefix, recursive);
ListIncompleteUploadsArgs args = new ListIncompleteUploadsArgs()
.WithBucket(bucketName)
.WithPrefix(prefix)
.WithRecursive(recursive);
IObservable<Upload> observable = minio.ListIncompleteUploads(args);

IDisposable subscription = observable.Subscribe(
item => Console.WriteLine($"OnNext: {item.Key}"),
Expand Down
54 changes: 42 additions & 12 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class FunctionalTest
private const string listObjectsSignature = "IObservable<Item> ListObjectsAsync(string bucketName, string prefix = null, bool recursive = false, CancellationToken cancellationToken = default(CancellationToken))";
private const string listObjectVersionsSignature = "IObservable<VersionItem> ListObjectVersionsAsync(ListObjectsArgs args, CancellationToken cancellationToken = default(CancellationToken))";

private const string listIncompleteUploadsSignature = "IObservable<Upload> ListIncompleteUploads(string bucketName, string prefix, bool recursive, CancellationToken cancellationToken = default(CancellationToken))";
private const string listIncompleteUploadsSignature = "IObservable<Upload> ListIncompleteUploads(ListIncompleteUploads args, CancellationToken cancellationToken = default(CancellationToken))";
private const string getObjectSignature1 = "Task GetObjectAsync(string bucketName, string objectName, Action<Stream> callback, CancellationToken cancellationToken = default(CancellationToken))";
private const string getObjectSignature2 = "Task GetObjectAsync(string bucketName, string objectName, Action<Stream> callback, CancellationToken cancellationToken = default(CancellationToken))";
private const string getObjectSignature3 = "Task GetObjectAsync(string bucketName, string objectName, string fileName, CancellationToken cancellationToken = default(CancellationToken))";
Expand All @@ -63,9 +63,9 @@ public class FunctionalTest
private const string removeObjectSignature1 = "Task RemoveObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default(CancellationToken))";
private const string removeObjectSignature2 = "Task<IObservable<DeleteError>> RemoveObjectAsync(string bucketName, IEnumerable<string> objectsList, CancellationToken cancellationToken = default(CancellationToken))";
private const string removeIncompleteUploadSignature = "Task RemoveIncompleteUploadAsync(string bucketName, string objectName, CancellationToken cancellationToken = default(CancellationToken))";
private const string presignedPutObjectSignature = "Task<string> PresignedPutObjectAsync(PresignedPutObjectArgs args)";
private const string presignedGetObjectSignature = "Task<string> PresignedGetObjectAsync(PresignedGetObjectArgs args)";
private const string presignedPutObjectSignature = "Task<string> PresignedPutObjectAsync(string bucketName, string objectName, int expiresInt)";
private const string presignedPostPolicySignature = "Task<Dictionary<string, string>> PresignedPostPolicyAsync(PostPolicy policy)";
private const string presignedPostPolicySignature = "Task<Dictionary<string, string>> PresignedPostPolicyAsync(PresignedPostPolicyArgs args)";
private const string getBucketPolicySignature = "Task<string> GetPolicyAsync(GetPolicyArgs args, CancellationToken cancellationToken = default(CancellationToken))";
private const string setBucketPolicySignature = "Task SetPolicyAsync(SetPolicyArgs args, CancellationToken cancellationToken = default(CancellationToken))";
private const string getBucketNotificationSignature = "Task<BucketNotification> GetBucketNotificationAsync(GetBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))";
Expand Down Expand Up @@ -2575,7 +2575,11 @@ internal async static Task PresignedPutObject_Test1(MinioClient minio)
{
await Setup_Test(minio, bucketName);
// Upload with presigned url
string presigned_url = await minio.PresignedPutObjectAsync(bucketName, objectName, 1000);
PresignedPutObjectArgs presignedPutObjectArgs = new PresignedPutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithExpiry(1000);
string presigned_url = await minio.PresignedPutObjectAsync(presignedPutObjectArgs);
await UploadObjectAsync(presigned_url, fileName);
// Get stats for object from server
StatObjectArgs statObjectArgs = new StatObjectArgs()
Expand Down Expand Up @@ -2630,7 +2634,11 @@ await minio.PutObjectAsync(bucketName,
.WithBucket(bucketName)
.WithObject(objectName);
ObjectStat stats = await minio.StatObjectAsync(statObjectArgs);
string presigned_url = await minio.PresignedPutObjectAsync(bucketName, objectName, 0);
PresignedPutObjectArgs presignedPutObjectArgs = new PresignedPutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithExpiry(0);
string presigned_url = await minio.PresignedPutObjectAsync(presignedPutObjectArgs);
}
catch (InvalidExpiryRangeException)
{
Expand Down Expand Up @@ -2693,7 +2701,11 @@ await minio.PutObjectAsync(bucketName,
fileName);
var pairs = new List<KeyValuePair<string, string>>();
string url = "https://s3.amazonaws.com/" + bucketName;
Tuple<string, System.Collections.Generic.Dictionary<string, string>> policyTuple = await minio.PresignedPostPolicyAsync(form);
PresignedPostPolicyArgs polArgs = new PresignedPostPolicyArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithPolicy(form);
Tuple<string, System.Collections.Generic.Dictionary<string, string>> policyTuple = await minio.PresignedPostPolicyAsync(polArgs);
var httpClient = new HttpClient();

using (var stream = File.OpenRead(fileName))
Expand Down Expand Up @@ -2760,11 +2772,19 @@ await minio.PutObjectAsync(bucketName,
}
catch (OperationCanceledException)
{
IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName);
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
.WithBucket(bucketName);
IObservable<Upload> observable = minio.ListIncompleteUploads(listArgs);

IDisposable subscription = observable.Subscribe(
item => Assert.AreEqual(item.Key, objectName),
ex => Assert.Fail());
item =>
{
StringAssert.Equals(item.Key, objectName);
},
ex =>
{
Assert.Fail();
});

await minio.RemoveIncompleteUploadAsync(bucketName, objectName);
}
Expand Down Expand Up @@ -2817,7 +2837,11 @@ await minio.PutObjectAsync(bucketName,
}
catch (OperationCanceledException)
{
IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName, "minioprefix", false);
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
.WithBucket(bucketName)
.WithPrefix("minioprefix")
.WithRecursive(false);
IObservable<Upload> observable = minio.ListIncompleteUploads(listArgs);

IDisposable subscription = observable.Subscribe(
item => Assert.AreEqual(item.Key, objectName),
Expand Down Expand Up @@ -2869,7 +2893,11 @@ await minio.PutObjectAsync(bucketName,
}
catch (OperationCanceledException)
{
IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName, prefix, true);
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
.WithBucket(bucketName)
.WithPrefix(prefix)
.WithRecursive(true);
IObservable<Upload> observable = minio.ListIncompleteUploads(listArgs);

IDisposable subscription = observable.Subscribe(
item => Assert.AreEqual(item.Key, objectName),
Expand Down Expand Up @@ -2923,7 +2951,9 @@ await minio.PutObjectAsync(bucketName,
{
await minio.RemoveIncompleteUploadAsync(bucketName, objectName);

IObservable<Upload> observable = minio.ListIncompleteUploads(bucketName);
ListIncompleteUploadsArgs listArgs = new ListIncompleteUploadsArgs()
.WithBucket(bucketName);
IObservable<Upload> observable = minio.ListIncompleteUploads(listArgs);

IDisposable subscription = observable.Subscribe(
item => Assert.Fail(),
Expand Down
Loading

0 comments on commit 67a519a

Please sign in to comment.