我正在使用Azure存储中的Block Blobs。我需要获得未提交的块,据我所知,我需要调用“Get Block List”。这是问题所在。
C#(Microsoft.WindowsAzure.StorageClient.dll)中是否存在“获取阻止列表”功能?
MSDN只说关于执行HTTP请求,而不是关于StorageClient API。
如果C#中不存在此功能,是否有计划将其包含在C#API中?
答案 0 :(得分:5)
我认为你要找的是CloudBlockBlob上的DownloadBlockList方法 http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblockblob.downloadblocklist.aspx
MSDN中的示例代码 - http://msdn.microsoft.com/en-us/library/ee772860.aspx
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();
}
}
答案 1 :(得分:0)
您可能需要查看Microsoft.WindowsAzure.StorageClient.Protocol命名空间中的GetBlockListResponse类:http://msdn.microsoft.com/en-us/library/ee758632.aspx
希望这有帮助
由于
拉夫