简体   繁体   English

DotNetZip 不会读取存储在 azure blob 存储中的 zip 中的所有条目

[英]DotNetZip doesn't read all entries from zip stored at azure blob storage

I have a zip stored in azure blob storage which I'm streaming it locally and iterating its entries.我有一个 zip 存储在 azure blob 存储中,我在本地流式传输它并迭代它的条目。

I'm getting the stream like that:我得到这样的 stream:

BlobClient blob = _blobServiceClientProp.GetBlobContainerClient(blobExtractionSource.ContainerName)
                                        .GetBlobClient(blobExtractionSource.BlobName);
            
Stream zipStream = await blob.OpenReadAsync().ConfigureAwait(false);

The stream length is valid (8890655642 bytes). stream 长度有效(8890655642 字节)。

Using DotNetZip 1.16, I'm reading from the zip stream:使用 DotNetZip 1.16,我正在读取 zip stream:

ZipFile zipFile = ZipFile.Read(zipStream);

The problem is that I'm getting wrong number of entries.问题是我输入的条目数有误。 According to DotNetZip, I have 41082 entries in the zip which is wrong.根据 DotNetZip,我在 zip 中有 41082 个条目,这是错误的。 I checked the number of entries both by the Entries property (zipFile.Entries) and also by iterating and count them manually.我通过 Entries 属性 (zipFile.Entries) 以及手动迭代和计数来检查条目数。

If I switch to IO.Compression.ZipArchive and iterating the zip entries, IO.Compression.ZipArchive is telling me I have 85,413 entries in the zip, which is the right number of entries.如果我切换到IO.Compression.ZipArchive并迭代 zip 条目, IO.Compression.ZipArchive告诉我 zip 中有 85,413 个条目,这是正确的条目数。

Any suggestions how can I still work with DotNetZip and make it get the right number of entries?有什么建议我仍然可以使用 DotNetZip 并使其获得正确数量的条目吗?

Note that when reading from the same zip locally (after I manually download it) with same version of DotNetZip, I successfully get all the entries.请注意,当使用相同版本的 DotNetZip 在本地读取相同的 zip(在我手动下载后)时,我成功获取了所有条目。

Through ZipArchive we could able to pull off the exact number.通过 ZipArchive,我们可以得出准确的数字。 Below is the code that worked for us.下面是对我们有用的代码。

var stream = await blobClient.OpenReadAsync();
using ZipArchive zip = new ZipArchive(stream, ZipArchiveMode.Read);
Console.WriteLine(zip.Entries.Count);

Edit编辑

The Code that worked for us using DotNetZip使用 DotNetZip 为我们工作的代码

BlobClient blob = blobServiceClient.GetBlobContainerClient("container-1")
                                        .GetBlobClient("samplezip1.zip");
Stream zipStream = await blob.OpenReadAsync().ConfigureAwait(false);
ZipFile zipFile = ZipFile.Read(zipStream);
Console.WriteLine(zipFile.Entries.Count);

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

相关问题 如何从存储在Azure blob存储中的json文件中获取数据 - How to get data from json file stored in Azure blob storage in react 无法从 Azure Blob 存储检索图像 - Could not retrieve image from Azure Blob Storage 从 azure blob 存储中获取文件名 - Get file names from azure blob storage 将文件从 Azure blob 存储移动到 Google 云存储桶 - Moving Files from Azure blob storage to Google cloud storage bucket Azure Blob 存储 - 如何读取源字符串:wasbs://training@dbtrainsouthcentralus.blob.core.windows.net - Azure Blob Storage - How to read source string: wasbs://training@dbtrainsouthcentralus.blob.core.windows.net 从 azure blob 存储(静态网站)访问 azure 密钥库 - Access azure key vault from azure blob storage (static website) 从笔记本电脑 spark 读取 Azure blob 存储中的文件时出错 - Error in reading files in Azure blob storage from laptop spark 直接从浏览器上传文件到 Azure Blob 存储? - Upload file to Azure Blob Storage directly from browser? 使用 .Net Core API 从 Azure Blob 存储异步流式传输视频 - Asynchronously Streaming Video with .Net Core API from Azure Blob Storage 测试 Azure Blob 存储 SDK - Testing Azure Blob Storage SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM