Skip to content

Commit 5fba6de

Browse files
Abel Milashclaude
andcommitted
Fix async file_upload example: use _AsyncResponse._body instead of .content
_AsyncResponse buffers the body in ._body; it has no .content attribute (unlike requests.Response used by the sync client). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e37fe4d commit 5fba6de

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

examples/aio/advanced/file_upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def main():
200200
async with client._scoped_odata() as od:
201201
dl_url = f"{od.api}/{entity_set}({record_id})/{small_file_attr_schema.lower()}/$value"
202202
resp = await od._request("get", dl_url)
203-
content = await resp.read() if hasattr(resp, "read") else (resp.content or b"")
203+
content = resp._body if hasattr(resp, "_body") else b""
204204

205205
downloaded_hash = hashlib.sha256(content).hexdigest() if content else None
206206
hash_match = (downloaded_hash == src_hash) if (downloaded_hash and src_hash) else None
@@ -270,7 +270,7 @@ async def main():
270270
async with client._scoped_odata() as od:
271271
dl_url = f"{od.api}/{entity_set}({record_id})/{chunk_file_attr_schema.lower()}/$value"
272272
resp = await od._request("get", dl_url)
273-
content_chunk = await resp.read() if hasattr(resp, "read") else (resp.content or b"")
273+
content_chunk = resp._body if hasattr(resp, "_body") else b""
274274

275275
dst_hash_chunk = hashlib.sha256(content_chunk).hexdigest() if content_chunk else None
276276
hash_match_chunk = (

0 commit comments

Comments
 (0)