terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
719 stars 74 forks source link

Update s3 streaming example #281

Closed steinnes closed 1 year ago

steinnes commented 1 year ago

As discussed here: https://github.com/terrycain/aioboto3/issues/266 the Body of an s3 object response is now a StreamingBody instance which has a read(amt) method, while the __aenter__ method on that same instance returns the underlying aiohttp client response object, where read() takes no arguments and does not stream (returns the entire body) I thought it would be prudent to update the example in the documentation.

The current example will result in a TypeError as disclosed in the issue referenced at the top of this commit:

TypeError: ClientResponse.read() takes 1 positional argument but 2 were given

... I additionally updated the example to be a bit more terse by using the walrus operator to be able to evaluate the read assignment in the loop.

terricain commented 1 year ago

Nice! +1 for walrus operator :wink: