See update at bottom - question slightly changed
I'm trying to download a file from s3 to a file-like object using boto3's .download_fileobj
method, however when I try to inspect the downloaded bytestream, it's empty. I'm not sure what I'm doing wrong however:
client = boto3.client('s3')
data = io.BytesIO()
client.download_fileobj(Bucket='mybucket', Key='myfile.wav', Fileobj=data)
print(data.read())
Which yields an empty bytestring:
b''
UPDATE :
kINDA SOLVED. So it turns out that adding data.seek(0)
after the download_fileobj
line solves the problem. In light of this, I am now looking for an answer that explains what this snippet does and why it fixes the problem.