gpt4 book ai didi

azure-storage - 能否从 Azure block Blob 下载特定 block ?

转载 作者:行者123 更新时间:2023-12-05 01:19:24 25 4
gpt4 key购买 nike

如果知道 block ID,是否可以从 Azure block Blob 下载特定 block ?

最佳答案

是的,你绝对可以,这是一个如何下载第一个 block 的例子:

var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net");

CloudBlobClient serviceClient = storageAccount.CreateCloudBlobClient();

var container = serviceClient.GetContainerReference("containerName");

var blockBlob = container.GetBlockBlobReference("blobName");

var blocklist = await blockBlob.DownloadBlockListAsync();

var firstBlock = blocklist.First();

var memStream = new MemoryStream();

await blockBlob.DownloadRangeToStreamAsync(memStream, 0, firstBlock.Length);

string contents;

using (var streamReader = new StreamReader(memStream))
{
contents = await streamReader.ReadToEndAsync();
}

你需要一些来自 nuget 的包:

Microsoft.WindowsAzure.Storage
Microsoft.WindowsAzure.Storage.Blob

关于azure-storage - 能否从 Azure block Blob 下载特定 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40117436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com