Skip to content

Commit

Permalink
Do not allow download_tmp_copy_of_file to download error responses as…
Browse files Browse the repository at this point in the history
… valid files
  • Loading branch information
akx committed Jun 27, 2023
1 parent 91932b4 commit 500dc72
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/python/gradio_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ def download_tmp_copy_of_file(
directory.mkdir(exist_ok=True, parents=True)
file_path = directory / Path(url_path).name

with requests.get(url_path, headers=headers, stream=True) as r, open(
file_path, "wb"
) as f:
shutil.copyfileobj(r.raw, f)
with requests.get(url_path, headers=headers, stream=True) as r:
r.raise_for_status()
with open(file_path, "wb") as f:
shutil.copyfileobj(r.raw, f)
return str(file_path.resolve())


Expand Down

0 comments on commit 500dc72

Please sign in to comment.