boto3提供了一种资源模型,该资源模型使诸如迭代对象之类的任务变得更加容易。不幸的是,StreamingBody不提供
readline或
readlines。
s3 = boto3.resource('s3')bucket = s3.Bucket('test-bucket')# Iterates through all the objects, doing the pagination for you. Each obj# is an ObjectSummary, so it doesn't contain the body. You'll need to call# get to get the whole body.for obj in bucket.objects.all(): key = obj.key body = obj.get()['Body'].read()


