小编Dav*_*veA的帖子

如何动态地将文件添加到存储在 Azure Blob 存储中的 zip 存档中?

我在 Azure 中有一个进程,可以生成大量 pdf 报告文件并将它们存储在 blob 存储中。我不是单独发送所有这些内容的链接,而是生成一个 zip 文件并将此链接发送给用户。

这个过程全部在一个进程中完成,并且一直运行良好。最近,我在将文件添加到 zip 存档时遇到了 OutOfMemory 异常错误,并且我正在努力寻找解决方案。

下面是我用来创建 zip 文件的代码(注意:使用 SharpLibZip 库)。目前,在添加大约 45 个每个文件 (PDF) 大约 3.5Mb 的文件后,它会失败并出现 OutOfMemoryException。当我点击以下行时发生故障:zipStream.PutNextEntry(newEntry)。

有谁知道我如何改进这个过程?压缩文件太小似乎会在这个级别失败。

Using outputMemStream As New MemoryStream()

    Using zipStream As New ICSharpCode.SharpZipLib.Zip.ZipOutputStream(outputMemStream)
          zipStream.SetLevel(7)

          Dim collD3 As UserSurveyReportCollection = GetFileList(RequestID)

          For Each entityD2 As UserSurveyReport In collD3

              Try
                  Dim strF As String = entityD2.FileLocation

                 'Download blob as memorystream and add this stream to the zip file
                 Dim msR As New MemoryStream 
                 msR = objA.DownloadBlobAsMemoryStream(azureAccount, ReportFolder, entityD2.FileName) …
Run Code Online (Sandbox Code Playgroud)

c# zip sharpziplib azure azure-storage

2
推荐指数
1
解决办法
4891
查看次数

标签 统计

azure ×1

azure-storage ×1

c# ×1

sharpziplib ×1

zip ×1