本文整理汇总了C#中Amazon.ListObjects方法的典型用法代码示例。如果您正苦于以下问题:C# Amazon.ListObjects方法的具体用法?C# Amazon.ListObjects怎么用?C# Amazon.ListObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon
的用法示例。
在下文中一共展示了Amazon.ListObjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRepositoryContents
/// <summary>
/// Gets the metadata contents of the repository on Amazon S3.
/// </summary>
/// <param name="client">The Amazon S3 client to use when connecting to the service.</param>
/// <returns>The current metadata contents of the repository.</returns>
private IEnumerable<FileObject> GetRepositoryContents(Amazon.S3.AmazonS3 client)
{
List<FileObject> objects = new List<FileObject>();
string marker = String.Empty;
bool truncated = true;
while (truncated)
{
ListObjectsRequest request = new ListObjectsRequest()
.WithBucketName(this.Bucket)
.WithPrefix(this.Prefix ?? String.Empty)
.WithMarker(marker);
try
{
using (ListObjectsResponse response = client.ListObjects(request))
{
objects.AddRange(response.S3Objects.Select(o => new FileObject(o)));
if (response.IsTruncated)
{
marker = objects[objects.Count - 1].Key;
}
else
{
truncated = false;
}
}
}
catch (AmazonS3Exception)
{
if (this.IgnoreMissingRoot)
{
truncated = false;
}
else
{
throw;
}
}
}
return objects;
}
示例2: GetImages
private ArrayList GetImages(Amazon.S3.AmazonS3 client, ListObjectsRequest request, string prefix, ArrayList image_list)
{
using (ListObjectsResponse response = client.ListObjects(request))
{
foreach (S3Object entry in response.S3Objects)
{
if (!entry.Key.Contains("."))
continue;
image_list.Add(prefix + entry.Key);
}
}
return image_list;
}