Skip to content

Commit 06c4fba

Browse files
Handle file-like objects in curlify (#2912)
1 parent 7728349 commit 06c4fba

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/huggingface_hub/utils/_http.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ def _curlify(request: requests.PreparedRequest) -> str:
578578
body = request.body
579579
if isinstance(body, bytes):
580580
body = body.decode("utf-8", errors="ignore")
581+
elif hasattr(body, "read"):
582+
body = "<file-like object>" # Don't try to read it to avoid consuming the stream
581583
if len(body) > 1000:
582584
body = body[:1000] + " ... [truncated]"
583585
parts += [("-d", body.replace("\n", ""))]

0 commit comments

Comments
 (0)