Skip to content

Commit

Permalink
New example of get_object (#1062)
Browse files Browse the repository at this point in the history
* get_object example
Co-authored-by: Alexander Mohr <[email protected]>

---------

Co-authored-by: Semyon Grigoriev <[email protected]>
Co-authored-by: Alexander Mohr <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2023
1 parent ab08687 commit 1ce6853
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ async def go():
resp = await client.get_object_acl(Bucket=bucket, Key=key)
print(resp)

resp = await client.get_object(Bucket=bucket, Key=key)
async with resp['Body'] as stream:
await stream.read() # if you do not read the stream the connection cannot be re-used and will be dropped
print(resp)
"""
This is to ensure the connection is returned to the pool as soon as possible.
Otherwise the connection will be released after it is GC'd
"""

# delete object from s3
resp = await client.delete_object(Bucket=bucket, Key=key)
print(resp)
Expand Down

0 comments on commit 1ce6853

Please sign in to comment.