【发布时间】:2015-08-14 02:29:00
【问题描述】:
我正在开发一个应用程序
使用简单的 HTTP 网页(REST 方法)从我的本地计算机上传 Azure Blob 存储上的 .CSV 文件
上传 .CSV 文件后,我获取流以更新我的数据库
.CSV 文件大约 30 MB,上传到 blob 需要 2 分钟,但读取流需要 30 分钟。 您能否提供意见以提高速度? 这是用于从文件中读取流的代码 sn-p: https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-how-to-use-blobs/
public string GetReadData(string filename)
{
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["StorageConnectionString"]);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference(System.Web.Configuration.WebConfigurationManager.AppSettings["BlobStorageContainerName"]);
// Retrieve reference to a blob named "filename"
CloudBlockBlob blockBlob2 = container.GetBlockBlobReference(filename);
string text;
using (var memoryStream = new MemoryStream())
{
blockBlob2.DownloadToStream(memoryStream);
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
return text;
}
【问题讨论】:
标签: c# csv azure azure-blob-storage memorystream