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

Zip64 support, and pre-calculating zip size! #7

Open
jhodges10 opened this issue Sep 9, 2021 · 1 comment
Open

Zip64 support, and pre-calculating zip size! #7

jhodges10 opened this issue Sep 9, 2021 · 1 comment

Comments

@jhodges10
Copy link

Hey there! I'm loving this library for my fastapi + zipstream approach to generating zips on the fly. The only drawback is that I'm hitting the 4GB file limit because I'm trying to zip image sequences up.

Any chance I could convince you to take a stab at that?

By the way, you can pre-calculate the size of zip files beforehand using this function. It's very helpful when using this with something like fastapi because you can set the content-length header in the response so you get progress in the browser. You have to get this perfect for the download to work properly though.

So if you do end up wanting to tackle zip64, we'll have to figure out the different padding amounts that go with that.

def calculate_zip_size(zip_queue: ZipQueue) -> int:
    # This is pretty hard to do, directions found here though!
    # https://stackoverflow.com/questions/10927442/calculate-size-of-zip-file-with-compression-level-0/19380600
    
    file_count = 0
    total_size = 0
    filename_chars = ""
    for file in zip_queue:
        info = os.stat(file['file']) # load file info
        total_size += info.st_size # size in bytes
        filename_chars += file['name'] # filename
        file_count += 1

    return file_count * (30+16+46) + 2 * len(filename_chars) + total_size + 22
@Raheela1024
Copy link

Hi,
I liked this library. It gives me the exact solution what i want but now i want to download files more than 5GB. it gives error after 5GB it gives error like struct.error: 'L' format requires 0 <= number <= 4294967295.
I just searched and found in zipfile if we pass allowZip64=True parameter it solve the problem but as i see in documentation this library is not supporting it.
are you planning to handle it ?

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

No branches or pull requests

2 participants