我试图读取存储在s3中的700mb文件。我只需要从73到1024的字节。
我试图找到一个可用的解决方案,但失败了。如果有人能帮我的话,那就太好了。
最佳答案
s3支持GET requests using the 'Range' HTTP header这正是您所追求的。
要在boto中指定Range请求,只需添加一个头字典,为您感兴趣的字节指定“Range”键改编自Mitchell Garnaat's response:
import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucket')
key = bucket.lookup('mykey')
your_bytes = key.get_contents_as_string(headers={'Range' : 'bytes=73-1024'})