dee
dee

Reputation: 147

Using the AWS SDK for .NET, how would we get a list of the filenames from the S3 bucket?

I want to know if it is possible to get a list of the filenames from an S3 bucket using the AWS SDK for .NET. So far I can only get a count of how many buckets I have.

Upvotes: 0

Views: 417

Answers (1)

Irene
Irene

Reputation: 94

It's true that the prefix parameter only specifies a pattern for the start of a name. There is a ListObjects example in GitHub as well: https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/dotnetv3/S3/ListObjectsExample

To modify the example to return only keys that begin with "d", for example, this is the only change you would have to make (the listObjectsV2Paginator definition starts at line 38 of the example):

var listObjectsV2Paginator = client.Paginators.ListObjectsV2(new ListObjectsV2Request
{
    BucketName = bucketName,
    Prefix = "d",
});

Upvotes: 1

Related Questions