本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.ListBlobsSegmented方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.ListBlobsSegmented方法的具体用法?C# CloudBlobContainer.ListBlobsSegmented怎么用?C# CloudBlobContainer.ListBlobsSegmented使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.ListBlobsSegmented方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectBlobs
public static IList<CloudBlockBlob> CollectBlobs(Logger log, CloudBlobContainer container, string prefix, Func<CloudBlockBlob, bool> condition = null, int? countEstimate = null)
{
List<CloudBlockBlob> list;
if (countEstimate.HasValue)
{
list = new List<CloudBlockBlob>(countEstimate.Value);
}
else
{
list = new List<CloudBlockBlob>();
}
BlobContinuationToken token = null;
do
{
var segment = container.ListBlobsSegmented(
prefix,
useFlatBlobListing: true,
blobListingDetails: BlobListingDetails.Copy,
maxResults: null,
currentToken: token,
options: new BlobRequestOptions(),
operationContext: new OperationContext());
var oldCount = list.Count;
int total = 0;
foreach (var blob in segment.Results.OfType<CloudBlockBlob>())
{
if (condition == null || condition(blob))
{
list.Add(blob);
}
total++;
}
log.Info("Matched {0}/{1} blobs in current segment. Found {2} blobs so far...", list.Count - oldCount, total, list.Count);
token = segment.ContinuationToken;
} while (token != null);
return list;
}
示例2: EnumerateBlobs
public static IEnumerable<CloudBlockBlob> EnumerateBlobs(Logger log, CloudBlobContainer container, string prefix, Func<CloudBlockBlob, bool> condition = null)
{
BlobContinuationToken token = null;
do
{
var segment = container.ListBlobsSegmented(
prefix,
useFlatBlobListing: true,
blobListingDetails: BlobListingDetails.Copy,
maxResults: null,
currentToken: token,
options: new BlobRequestOptions(),
operationContext: new OperationContext());
foreach (var blob in segment.Results.OfType<CloudBlockBlob>().Where(b => condition == null || condition(b)))
{
yield return blob;
}
token = segment.ContinuationToken;
} while (token != null);
}
示例3: ListBlobsSegmented
/// List part of blobs.
/// </summary>
/// <param name="prefix">Blob prefix</param>
/// <param name="useFlatBlobListing">Use flat blob listing</param>
/// <param name="blobListingDetails">Blob listing details.</param>
/// <param name="maxResults">Max results.</param>
/// <param name="currentToken">Current token.</param>
/// <param name="options">Request options</param>
/// <param name="operationContext">Operation Context.</param>
/// <returns>BlobResultSegment object</returns>
public BlobResultSegment ListBlobsSegmented(CloudBlobContainer container, string prefix, bool useFlatBlobListing,
BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken, BlobRequestOptions options, OperationContext operationContext)
{
return container.ListBlobsSegmented(prefix, useFlatBlobListing, blobListingDetails, maxResults, currentToken, options, operationContext);
}
示例4: TestAccessTask
private static void TestAccessTask(BlobContainerPublicAccessType accessType, CloudBlobContainer container, CloudBlob inputBlob)
{
StorageCredentials credentials = new StorageCredentials();
container = new CloudBlobContainer(container.Uri, credentials);
CloudPageBlob blob = new CloudPageBlob(inputBlob.Uri, credentials);
if (accessType.Equals(BlobContainerPublicAccessType.Container))
{
blob.FetchAttributesAsync().Wait();
BlobContinuationToken token = null;
do
{
BlobResultSegment results = container.ListBlobsSegmented(token);
results.Results.ToArray();
token = results.ContinuationToken;
}
while (token != null);
container.FetchAttributesAsync().Wait();
}
else if (accessType.Equals(BlobContainerPublicAccessType.Blob))
{
blob.FetchAttributesAsync().Wait();
TestHelper.ExpectedExceptionTask(
container.ListBlobsSegmentedAsync(null),
"List blobs while public access does not allow for listing",
HttpStatusCode.NotFound);
TestHelper.ExpectedExceptionTask(
container.FetchAttributesAsync(),
"Fetch container attributes while public access does not allow",
HttpStatusCode.NotFound);
}
else
{
TestHelper.ExpectedExceptionTask(
blob.FetchAttributesAsync(),
"Fetch blob attributes while public access does not allow",
HttpStatusCode.NotFound);
TestHelper.ExpectedExceptionTask(
container.ListBlobsSegmentedAsync(null),
"List blobs while public access does not allow for listing",
HttpStatusCode.NotFound);
TestHelper.ExpectedExceptionTask(
container.FetchAttributesAsync(),
"Fetch container attributes while public access does not allow",
HttpStatusCode.NotFound);
}
}
示例5: EnumerateBlobsInContainer
private List<string> EnumerateBlobsInContainer(CloudBlobContainer logsContainer, string blobPrefix)
{
var blobNames = new List<string>();
int pagingCount = 1000;
var continuationToken = new BlobContinuationToken();
var context = new OperationContext();
context.ClientRequestID = "LogAnalysisTool";
BlobResultSegment resultSegment;
//Check whether there are more results and list them in pages of 1000.
do
{
resultSegment = logsContainer.ListBlobsSegmented(
blobPrefix, true, BlobListingDetails.Snapshots, pagingCount, continuationToken, null, context);
foreach (IListBlobItem blobItem in resultSegment.Results)
{
string blobName;
blobName = blobItem.Uri.AbsolutePath.Remove(0, "/$logs/blob/".Length);
blobNames.Add(blobName);
}
continuationToken = resultSegment.ContinuationToken;
}
while (continuationToken != null);
return blobNames;
}