Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download 1MB chunks streaming #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 9 additions & 7 deletions batch-result-download.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@
" status = r.status_code\n",
" \n",
" if (status == 200):\n",
" zipRequest = requests.get(r.json()['url'], verify = False)\n",
"\n",
" # Save result to a local .zip file\n",
" with open('results/' + analysisId + '.zip', 'wb') as f:\n",
" for chunk in zipRequest.iter_content(chunk_size=128):\n",
" f.write(chunk)\n",
" f.close()"
" with requests.get(r.json()['url'], verify = False, stream=True) as zipRequest:\n",
" zipRequest.raise_for_status()\n",
" humanName = r.json()['humanName']\n",
" print('Saving results to local file: ' + humanName)\n",
" with open(humanName, 'wb') as f:\n",
" for (i, chunk) in enumerate(zipRequest.iter_content(chunk_size=1024*1024)):\n",
" print(i, \"MB\")\n",
" f.write(chunk)\n",
" print(\"Done.\")\n"
]
}
],
Expand Down