You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
attempt to store data in it. - using the store compression method
it gets set as deflation method, but with 0% compression.
Expected behavior
Tell us what should happen
it should be stored and not encrypted.
Actual behavior
Tell us what happens instead
it gets run through the compression algorithm, albeit with no compression.
Version of SharpZipLib
1.2.0
Obtained from (only keep the relevant lines)
Package installed using NuGet (via dotnet add)
we have noticed at least some performance impact from not just copying the data, i am returning the zip on the fly from a web api as a stream, this means i cannot have a seekable stream.
i am zipping several large (40MB+) pdf and tiff images, that only slow down the compression, in the previous api we used DotNetZip and it worked fine and fast.
it took my some time via digging through your code and debugging what a 'can patch' stream is.
but is there any way of doing this as part of a write only stream? why does the stream need to be patchable?
// Can't patch entries so storing is not possible.
looks to force the compression method to deflated when header information is unavailable, but i'm not sure if that's 'required' as such, or is just something it does to ensure that ZipInputStream can read the produced zip.
Doesn't look like the behaviour is presently configurable, other than via populating all the header fields on the entry directly before adding it?
Yeah, this is because PKZIP 2 only supported descriptors for Deflate compression (descriptors come after the file data, which is necessary when we cannot seek in the stream and update the CRC and size after the data has been copied).
I will make a PR that enables GeneralBitFlags.Descriptor for Stored compression, since compability with a 30 year old software version hardly seems justified.
This is not possible to accomplish due to how the zip file format works and the comment about only supporting it for Deflate was meant to imply just that. See the InfoZip comment in #407
Activity
Dedme commentedon Sep 12, 2019
on top is this library on dotnet core, the bottom is the old dotnetzip, on .net 4.7

Dedme commentedon Sep 12, 2019
i went back to dotnetzip - when i started some months ago it didn't seem to be very core/.net Standard compliant, now it is.
Numpsy commentedon Sep 15, 2019
The logic at
SharpZipLib/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs
Line 259 in ab7f8c5
looks to force the compression method to deflated when header information is unavailable, but i'm not sure if that's 'required' as such, or is just something it does to ensure that ZipInputStream can read the produced zip.
Doesn't look like the behaviour is presently configurable, other than via populating all the header fields on the entry directly before adding it?
piksel commentedon Dec 31, 2019
Yeah, this is because PKZIP 2 only supported descriptors for Deflate compression (descriptors come after the file data, which is necessary when we cannot seek in the stream and update the CRC and size after the data has been copied).
I will make a PR that enables
GeneralBitFlags.DescriptorforStoredcompression, since compability with a 30 year old software version hardly seems justified.piksel commentedon Nov 22, 2020
This is not possible to accomplish due to how the zip file format works and the comment about only supporting it for Deflate was meant to imply just that. See the InfoZip comment in #407