Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InflaterInputStream Length is not supported The unsupported member type is located on type 'System.Int64'. Path: $.Length. #785

Closed
enti333 opened this issue Oct 16, 2022 · 3 comments

Comments

@enti333
Copy link

enti333 commented Oct 16, 2022

Steps to reproduce

After Migration from azure function .net framework to Azure Function Asp 6 unzipping stops working.
I have a simple code:

ZipFile zf = new ZipFile(fileStream);
zf.Password = zipPassword;

foreach (ZipEntry entry in zf)
{
    if (entry.IsFile)
    {
        Console.WriteLine("Extracting {0}", entry.Name);
        log.LogInformation("Extracting {0}", entry.Name);

        Stream stream = zf.GetInputStream(entry);
        byte[] byteS = stream.ToByteArray();

When I try to work with this stream I get the error:
InflaterInputStream Length is not supported The unsupported member type is located on type 'System.Int64'. Path: $.Length.

On the last row of code...Or if I try to upload a stream somewhere I still get the same error.
InflaterInputStream Length is not supported

I do not know what to do whit this because the same code was working on .net framework.
Thank you for your help.

Expected behavior

Getting the file stream from zipped file

Actual behavior

Exception

Version of SharpZipLib

Latest

Obtained from (only keep the relevant lines)

  • Package installed using NuGet
@piksel
Copy link
Member

piksel commented Oct 17, 2022

I don't know ToByteArray does, but if you really want the entry contents as a byte buffer you could do:

var ms = new MemoryStream(entry.Size);
zf.GetInputStream.CopyTo(ms);
var bytes = ms.ToArray();

The InflaterInputStream does not know what it's final size will be until all data is read.

@arnileibovits
Copy link

This is a bug. Uncompressed size is available in entry.Size, so why isn't it available in Stream.Length?

@piksel
Copy link
Member

piksel commented Sep 7, 2023

It's not a bug. Even though the information is available in the entry, the stream itself doesn't know and does not support seeking. Since the stream does not have the same number bytes read for the same number of bytes written, the concept of Length is confusing at best and is therefore avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants