'Zipfile can't open a file-like object streaming in request.raw

When I want to decompression a zipfile from internet, there is a error like zipfile.badzipfile: file is not a zip file. here is my code:

response = requests.get('www.example.com/somefile.zip', stream=True)
response.raw.decode_content = True
with zipfile.ZipFile(response.raw)as zip_file:
    # do something.

PS: Because this zipfile is very large, I don't want to waste memory, so I didn't use io.BytesIO(resp.content) as there 1 says.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source