【发布时间】:2021-04-21 06:08:38
【问题描述】:
我可以使用此代码读取 txt 文件,但是当我尝试读取 txt.gz 文件时,它当然不起作用。 我如何在不下载的情况下阅读压缩的 blob,因为该框架可以在云上运行? 也许可以将文件解压缩到另一个容器?但我找不到解决方案。
public static string GetBlob(string containerName, string fileName)
{
string connectionString = $"yourConnectionString";
// Setup the connection to the storage account
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
// Connect to the blob storage
CloudBlobClient serviceClient = storageAccount.CreateCloudBlobClient();
// Connect to the blob container
CloudBlobContainer container = serviceClient.GetContainerReference($"{containerName}");
// Connect to the blob file
CloudBlockBlob blob = container.GetBlockBlobReference($"{fileName}");
// Get the blob file as text
string contents = blob.DownloadTextAsync().Result;
return contents;
}
【问题讨论】:
-
你知道gz和zipping不一样吗?
-
哦,是的,谢谢,但是gz也有问题,我需要.txt文件。
标签: c# azure azure-blob-storage unzip