Boto3 S3 StreamingBody().read() reads once and returns nothing after that
See original GitHub issue>>> a = client.get_object(Bucket='imgtest',Key='testimage1.jpg')
>>> a['Body'].read()
b'...\xadk\xc9,\xda\xe7\xcb\xb7$\x91\xf7\xb3\xd3>\xd5V...'
>>> a['Body'].read()
b''
complete bytes removed for brevity. I get an object, and read it. Then I read it again, but no bytes are returned.
If this stream acts as a normal file IO stream, how can I seek to the beginning of the stream? seek() does not seem to be a method on the streamingBody object.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Unable to read botocore.response.StreamingBody due to ...
The object is returned as botocore.response.Streamingbody . Usually it can be read using strmingbody.read() method. But when I try to use read, ...
Read more >Response Reference — botocore 1.29.34 documentation - AWS
Return an iterator to yield lines from the raw stream. This is achieved by reading chunk of bytes (of size chunk_size) at a...
Read more >Streaming S3 objects in Python | blog
First, I set up an S3 client and looked up an object. import boto3 s3 = boto3.client('s3', aws_access_key_id='mykey', aws_secret_access_key=' ...
Read more >How to read a file from S3 with the Python SDK - YouTube
In this video I will show you how to get and read a text file from Amazon S3 using Boto3, the Python SDK...
Read more >How to read CSV file from Amazon S3 in Python
import codecs import csv import boto3 client = boto3.client("s3") def ... interested in is the return value of the get_object() method call.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there a reason why the StreamingBody, is not seekable? This becomes quite problematic when attempting to download portions of large files asynchronously. And what is the recommended way to do this?
If someone is having the problem
'bytes' object has no attribute 'seek'
I solved with the following: