413 questions
0
votes
0
answers
51
views
Error on testing password for zip file: zlib.error: Error -3 while decompressing data: invalid block type
I am trying to find the forgotten password for my zip file with following code:
while found == False:
password = bytes(word, 'utf-8')
print('Trying ' + word)
zip = zipfile.ZipFile(zipFilename)...
1
vote
3
answers
351
views
Safely extract uploaded ZIP files in Python
I'm working on a python REST API that allows users to upload ZIP files. Before extracting them, I want to protect against common vulnerabilities, especially Zip bombs. Is there a way (ideally based on ...
0
votes
1
answer
64
views
Adding Password to Zip file with BytesIO
I am working on a project in which I need to zip a Word document and then upload the file to a Blob Storage in Azure with a password on the zip file. At this point in time I have managed to get the ...
0
votes
1
answer
43
views
Python3: ZIP file as input to cgi script
What I'm trying to do: I want to send a ZIP file to a Python 3 CGI script over the web. Not as a form, just a payload with Content-Type application/zip that I can extract a relevant file from and ...
0
votes
1
answer
52
views
Error 422: Unprocessable Entity errors with Openstack python-swiftclient
I am writing a Python script using python-swiftclient and zipfile to zip and upload files to the Swift API endpoint of an Openstack Object Store. I store the zipped data in memory as an io.BytesIO ...
0
votes
1
answer
69
views
How do we unzip a zip file in the file's parent folder in python3.x
I have a requirement to unzip an archive by selecting it at runtime.
I am passing the zip file using HTML input type file in my template and then using ZipFile's function extractall(). This ...
0
votes
1
answer
108
views
Function to unzip .zip file in Python not working
I have this function which is supposed to take a .zip file, unzip it, and put the files in the same directory where the .zip file was originally located:
def unzip_file(file_path):
print(f"...
0
votes
1
answer
47
views
Trying to access a .gz file inside a .zip file through Python
I have a .zip file with a large amount of .gz files, which I need to process. I want to open the .zip, which I can easily do through this code:
zf = zipfile.ZipFile("file.zip", "r")...
0
votes
1
answer
50
views
Extracting contents from Zipfile in Python downloaded from URL
I have this URL for downloading a Zipfile.
We can download the zipfile by clicking the link.
But this code I have does not work.
from datetime import datetime, timedelta
import requests, zipfile, io
...
0
votes
1
answer
111
views
How to set compression level while using `zipfile` with LZMA compression?
Documention for zipfile notes that the compresslevel argument does nothing for when LZMA compression is used. So how can the LZMA compression level be set for ZIP files created with Python.
See: https:...
1
vote
1
answer
81
views
Reading zipped csv and adding new lines
I have a zip file t.zip containing two csv files. The first one is s.csv (30kB) and the other is p.csv (60GB).
What I'm doing now is unzipping p.csv to the disk, reading the second last line, doing ...
0
votes
2
answers
548
views
How do I use Python 3.12 zipfile to extract all the data in a complex zip file
I'm using this code:
with ZipFile(sourceZip, mode="r") as extraction:
extraction.extractall(extractionPath)
extraction.close()
What happens is it only extracts the first layer of ...
0
votes
0
answers
30
views
Python. Unzip archive to which the filenames are encoded using urlencode, and because of the encoding, the length of some names is > 260
Creating a backend on FastApi. Post request, the bytes string is received. After that, I create a zip archive from this line. But the file names are encoded using url encoding.
data: bytes - bytes ...
1
vote
0
answers
184
views
python check if compressed file is password-protected with just a small part of a file
I want to check if some .rar or .zip files are password-protected or not. There are packages (zipfile, rarfile) with some specific methods (testzip, tetrar) that can check if the file is password-...
0
votes
1
answer
168
views
Why is my zip file not the same size as the zip file I'm trying to copy?
I'm writing a python script to append files from an old jar file to the a new jar file, but the file size of the new file isn't exactly the same as the original file. The original.jar is 6,786 KB and ...