Returns an enumerable collection of the blob's blocks, using the specified block list filter. Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
Visual Basic |
---|
Dim instance As CloudBlockBlob Dim blockListingFilter As BlockListingFilter Dim options As BlobRequestOptions Dim returnValue As IEnumerable(Of ListBlockItem) returnValue = instance.DownloadBlockList(blockListingFilter, options) |
Syntax
Visual Basic |
---|
Public Function DownloadBlockList ( _ blockListingFilter As BlockListingFilter, _ options As BlobRequestOptions _ ) As IEnumerable(Of ListBlockItem) |
C# |
---|
public IEnumerable<ListBlockItem> DownloadBlockList ( BlockListingFilter blockListingFilter, BlobRequestOptions options ) |
C++ |
---|
public: IEnumerable<ListBlockItem^>^ DownloadBlockList ( BlockListingFilter blockListingFilter, BlobRequestOptions^ options ) |
J# |
---|
JScript |
---|
Parameters
- blockListingFilter
Type: Microsoft.WindowsAzure.StorageClient.BlockListingFilter
One of the enumeration values that indicates whether to return committed blocks, uncommitted blocks, or both.
- options
Type: Microsoft.WindowsAzure.StorageClient.BlobRequestOptions
An object that specifies any additional options for the request.
Return Value
Type: System.Collections.Generic.IEnumerable An enumerable collection of objects implementing ListBlockItem.Example
The following code example downloads the block list for a blob and enumerates the blocks in the list. The example first downloads the committed blocks, then the uncommitted blocks, then the entire block list.
C# | Copy Code |
---|---|
static void DownloadBlockListForBlob(Uri blobEndpoint, string accountName, string accountKey) { //Create service client for credentialed access to the Blob service, using development storage. CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey)); //Get a reference to a block blob. CloudBlockBlob blockBlob = blobClient.GetBlockBlobReference("mycontainer/mybinaryblob.mp3"); //Download the committed blocks in the block list. foreach (var blockListItem in blockBlob.DownloadBlockList()) { Console.WriteLine("Block ID: " + blockListItem.Name); Console.WriteLine("Block size: " + blockListItem.Size); Console.WriteLine("Is block committed?: " + blockListItem.Committed); Console.WriteLine(); } //Download only uncommitted blocks. foreach (var blockListItem in blockBlob.DownloadBlockList(BlockListingFilter.Uncommitted)) { Console.WriteLine("Block ID: " + blockListItem.Name); Console.WriteLine("Block size: " + blockListItem.Size); Console.WriteLine("Is block committed?: " + blockListItem.Committed); Console.WriteLine(); } //Download all blocks. foreach (var blockListItem in blockBlob.DownloadBlockList(BlockListingFilter.All)) { Console.WriteLine("Block ID: " + blockListItem.Name); Console.WriteLine("Block size: " + blockListItem.Size); Console.WriteLine("Is block committed?: " + blockListItem.Committed); Console.WriteLine(); } } |
Remarks
The DownloadBlockList method downloads the block list for the blob, using the specified block listing filter. The block listing filter specifies whether to include only committed blobs, only uncommitted blobs, or both.
The committed block list includes the list of blocks that have been successfully committed to a blob. The list of committed blocks is returned in the same order that they were committed to the blob. No block may appear more than once in the committed block list.
You can use the uncommitted block list to determine which blocks are missing from the blob in cases where writing a block or the block list has failed. The list of uncommitted blocks is returned beginning with the most recently uploaded block to the oldest uploaded block. If a block ID has been uploaded more than once, only the most recently uploaded block appears in the list.
When blocks have been uploaded but the blob has not yet been committed with PutBlockList, calling DownloadBlockList with All returns the uncommitted blocks.