Skip to content
Snippets Groups Projects
Commit b51e6a4a authored by kosted's avatar kosted
Browse files

add download by chunck

parent 444f3272
No related branches found
No related tags found
No related merge requests found
......@@ -293,9 +293,9 @@ def download(path, name):
if location:
#We download the data using the location
print("[INFO] we are about to download the data")
response = requests.get(location)
open(name, 'wb').write(response.content)
download_file(location, name)
#response = requests.get(location)
#open(name, 'wb').write(response.content)
print("[INFO] Download finished")
else:
......@@ -303,6 +303,21 @@ def download(path, name):
##########################
# download file using url #
##########################
def download_file(url, name):
#local_filename = url.split('/')[-1]
# NOTE the stream=True parameter below
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open(name, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
#if chunk:
f.write(chunk)
return name
##########################
# list data in s3 folder #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment