There must be an easy way to get the file size (key size) without pulling over a whole file. I can see it in the Properties of the AWS S3 browser. And I think I can get it off the "Content-length" header of a "HEAD" request. But I'm not connecting the dots about how to do this with boto. Extra kudos if you post a link to some more comprehensive examples than are in the standard boto docs.
EDIT: So the following seems to do the trick (though from looking at source code I'm not completely sure.):
bk = conn.get_bucket('my_bucket_name')
ky = boto.s3.key.Key(bk)
ky.open_read() ## This sends a GET request.
print ky.size
For now I'll leave the question open for comments, better solutions, or pointers to examples.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…