How do I get the file / key size in boto S3?

后端 未结 5 1908
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 05:33

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

5条回答
  •  清歌不尽
    2020-12-13 06:26

    in boto3 using an S3 resource:

    boto3.resource('s3').Bucket(bucketname).Object(keyname).content_length
    

    The head_object call of the S3 client returned me an http "403 Forbidden"

提交回复
热议问题