For example, suppose I have a bucket in an area USEast1called MyBucketName, with the following keys:
temp/
temp/foobar.txt
temp/txt/
temp/txt/test1.txt
temp/txt/test2.txt
temp2/
, S3 - , , S3. - , - S3, . , , , "" ( '/', size = 0), "", S3.
: NuGet 3.1 AWSSDK.S3.
1:
S3, . , /, .
IAmazonS3 client;
using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1))
{
ListObjectsRequest request = new ListObjectsRequest
{
BucketName = "MyBucketName"
};
do
{
ListObjectsResponse response = client.ListObjects(request);
IEnumerable<S3Object> folders = response.S3Objects.Where(x =>
x.Key.EndsWith(@"/") && x.Size == 0);
folders.ToList().ForEach(x => System.Console.WriteLine(x.Key));
if (response.IsTruncated)
{
request.Marker = response.NextMarker;
}
else
{
request = null;
}
} while (request != null);
}
:
temp/
temp/txt/
temp2/
2: ,
, , Prefix, Prefix ListObjectsRequest.
ListObjectsRequest request = new ListObjectsRequest
{
BucketName = "MyBucketName",
Prefix = "temp/"
};
1 :
temp/
temp/txt/
: