Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self.tmpdir = tempfile.mkdtemp()
- with open(self.tmpdir+"\\"+fname, 'wb') as f:
- response = requests.get(url, stream=True)
- total = response.headers.get('content-length')
- if total is None:
- f.write(response.content)
- else:
- downloaded = 0
- total = int(total)
- for data in response.iter_content(chunk_size=max(int(total/1000), 1024*1024)):
- downloaded += len(data)
- f.write(data)
Add Comment
Please, Sign In to add comment