简体   繁体   English

在 Service Fabric 应用程序中下载 2 GB 文件

[英]Download 2 GB file in Service Fabric application

I am designing an application which will support upload and download of XML file with limit of 2 GBs.我正在设计一个应用程序,它将支持 XML 文件的上传和下载,限制为 2 GB。 I am using Azure Blob Storage as persistent storage to upload these files and then download them.我使用 Azure Blob 存储作为持久存储来上传这些文件,然后下载它们。 Below piece of code throws OutOfMemory exception:下面的代码抛出 OutOfMemory 异常:

 var blob = this.GetBlockBlobReference(blobId, blobContainerName);
 return await blob.DownloadTextAsync().ConfigureAwait(false);

Also, I am not sure which approach will be faster and cleaner.另外,我不确定哪种方法会更快更清洁。

For faster downloading / uploading blobs, you can consider using Microsoft Azure Storage Data Movement Library .为了更快地下载/上传 Blob,您可以考虑使用Microsoft Azure 存储数据移动库 This library is designed for high-performance uploading, downloading and copying Azure Storage Blob and File.该库专为高性能上传、下载和复制 Azure 存储 Blob 和文件而设计。

You can set parallel threads via code below:您可以通过以下代码设置并行线程:

// Setup the number of the concurrent operations
TransferManager.Configurations.ParallelOperations = 64;

Then use TransferManager.UploadAsync or TransferManager.DownloadAsync method for uploading / downloading blobs respectively.然后分别使用TransferManager.UploadAsyncTransferManager.DownloadAsync方法上传/下载 Blob。

There is an example in github of uploading, you can modify it for downloading easily.上传的github中有一个例子,你可以修改它以方便下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM