TenzinGayche commited on
Commit
7c0103d
·
verified ·
1 Parent(s): 8a167a2

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +16 -3
handler.py CHANGED
@@ -229,9 +229,22 @@ def TemporaryDirectory():
229
  shutil.rmtree(str(tmpdir))
230
 
231
 
232
- def download_file(s3_public_url: str, output_fn) -> Path:
233
- """Download file from a public S3 bucket URL."""
234
- with requests.get(s3_public_url, stream=True) as r:
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  r.raise_for_status()
236
  with open(output_fn, "wb") as f:
237
  for chunk in r.iter_content(chunk_size=8192):
 
229
  shutil.rmtree(str(tmpdir))
230
 
231
 
232
+ # def download_file(s3_public_url: str, output_fn) -> Path:
233
+ # """Download file from a public S3 bucket URL."""
234
+ # with requests.get(s3_public_url, stream=True) as r:
235
+ # r.raise_for_status()
236
+ # with open(output_fn, "wb") as f:
237
+ # for chunk in r.iter_content(chunk_size=8192):
238
+ # f.write(chunk)
239
+ # return output_fn
240
+ def download_file(github_file_url: str, output_fn) -> Path:
241
+ """Download file from github"""
242
+ headers = {
243
+ "Authorization": f"token {GITHUB_TOKEN}",
244
+ "Accept": "application/vnd.github+json",
245
+ }
246
+ authenticated_file_url = f"{github_file_url}?token={GITHUB_TOKEN}"
247
+ with requests.get(authenticated_file_url, headers=headers, stream=True) as r:
248
  r.raise_for_status()
249
  with open(output_fn, "wb") as f:
250
  for chunk in r.iter_content(chunk_size=8192):