Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zipstream/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
DD_STRUCT64 = struct.Struct(b"<LQQ")
DD_TUPLE = namedtuple("filecrc",
("crc", "comp_size", "uncomp_size"))
DD_MAGIC = b'\x08\x07\x4b\x50'
DD_MAGIC = b'\x50\x4b\x07\x08'


# central directory file header
Expand Down
12 changes: 12 additions & 0 deletions zipstream/zipstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
import os
import time
import urllib
import zlib
from . import consts

Expand Down Expand Up @@ -113,6 +114,9 @@ def _create_file_struct(self, data):
if 'file' in data:
file_struct['src'] = data['file']
file_struct['stype'] = 'f'
elif 'url' in data:
file_struct['src'] = data['url']
file_struct['stype'] = 'u'
elif 'stream' in data:
file_struct['src'] = data['stream']
file_struct['stype'] = 's'
Expand Down Expand Up @@ -274,6 +278,14 @@ def data_generator(self, src, src_type):
break
yield part
return
if src_type == 'u':
with urllib.request.urlopen(src) as fh:
while True:
part = fh.read(self.chunksize)
if not part:
break
yield part
return

def _stream_single_file(self, file_struct):
"""
Expand Down