Skip to content

Unable to list object in an S3 regional bucket #673

@anthonyMc11

Description

@anthonyMc11

I am using the following code:

` class Program
{
static async Task Main()
{
var bucket = "my-bucket-name";
var filePrefix = "379c05ee-d204-4dc7-b26b-66ad8f9e68d4/";

        var _mediaClient = new MinioClient().WithEndpoint("s3.amazonaws.com").WithCredentials("myaccesskey",
            "mysecretkey").WithSSL().WithRegion("eu-west-2").Build();

        var exists = await _mediaClient.BucketExistsAsync(bucket);

        if (exists)
        {
            ListObjectsArgs args = new ListObjectsArgs().WithPrefix(filePrefix).WithRecursive(true)
                .WithBucket(bucket).WithListObjectsV1(false);
            IObservable<Item> observable = _mediaClient.ListObjectsAsync(args);
            var files = await observable.Select(item => item.Key).ToList();
            foreach (var file in files)
            {
                Console.WriteLine(file);
            }
        }
    }
}`

I am getting a perminent redirect error when the observable.Select(item => item.Key).ToList(); runs. I have diagnosed this to the to line 299 of the minioclient.cs

if (!string.IsNullOrEmpty(objectName) && method != HttpMethod.Put) region = await GetRegion(bucketName).ConfigureAwait(false);

because I'm doing a list operation, the objectName is null and I'm not doing a Put request, therefore the region isn't loaded, and causes the above error.

I have rebuilt the code without this check and loaded the region and the code now works as expected, however this has broken a unit test TestInvalidObjectNameError()

Could you please assist as I can't list my objects, thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions