[not our bug] how to use ListObjectsAsync?
See original GitHub issueGood morning.
I am using Minio (dotnet) SDK 3.0.2 but this case is also the same in (the current) 3.0.8 version.
Since the SDK does not provide anything easy like that I tried my self to implement a function that returns a list of all keys in a bucket (at the given time it is called).
It looks like that (well, one problem is that the command line tool does not have async methods):
public List<string> GetMinioBucketKeys()
{
List<string> bucketKeys = new List<string>();
IObservable<Minio.DataModel.Item> observable = _minio.ListObjectsAsync(_minioBucketName);
IDisposable subscription = observable.Subscribe
(
item => bucketKeys.Add(item.Key), // onNext
ex => throw new Exception("GetMinioBucketKeys subscription raised an exception", ex), // onError
() => Log($"GetMinioBucketKeys completed and collected {bucketKeys.Count} bucket keys") // onCompleted
);
subscription.Dispose();
return bucketKeys;
}
I ensured (at the initialization of minio client) that the bucket exists. I uploaded two files and expected to get a list with the two bucket keys. I received an empty list.
In order to evaluate what I am doing wrong I took your ListObjects example and tested it using it as:
Minio.Examples.Cases.ListObjects.Run(_minio, "test", null, true);
The result is the same. No files are detected. Tested with 3.0.2 and 3.0.8.
The single log line in the console is “Running example for API: ListObjectsAsync”. I would at least miss the line “Listed all objects in bucket test” written on OnCompleted in the sample.
Is this some bug (since the official code samples too do not detect any files in the bucket)?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
you will need to await the observable if you want to collect the items into a list as ListObjectsAsync is an async operation
That was it. Thank you very much.