boto s3存储桶与get_bucket [英] boto s3 Bucket versus get_bucket

查看:135
本文介绍了boto s3存储桶与get_bucket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试访问存储桶中的一个密钥,尽管我对此没有权限,但是我没有权限. 为了能够执行get_key('this/is/my_key'),我需要bucket对象:

I try to access a key inside a bucket, for which I don't have permissions, though I do for the key. In order to be able to do get_key('this/is/my_key'), I need the bucket object:

conn = boto.connect_s3(key, secret_key)
my_bucket = conn.get_bucket('a_bucket')

产量S3ResponseError: S3ResponseError: 403 Forbidden.

另一方面,以下作品

my_bucket = boto.s3.bucket.Bucket(conn, 'a_bucket')
my_bucket.get_key('this/is/my_key')

问题:创建对象Bucket和使用get_bucket方法有什么区别? 检查 docu 我仅查看检查以进行验证.还有吗?

Question: What is the difference between creating the object Bucket and using the get_bucket method? Checking the docu I only see the check for validation. Anything else?

推荐答案

验证(默认为validate=True)在调用时检查存储桶的存在.由于您无权访问该存储桶,因此您的请求被拒绝(403).在另一种情况下,类实例化似乎没有进行验证,因此get_key方法可以按预期工作.

Validation (validate=True default) in the get_bucket checks for bucket's existence when called. Since you don't have access to the bucket, your request is turned down (403). In the other case, the class instantiation doesn't seem to do the validation, hence the get_key method works as intended.

这篇关于boto s3存储桶与get_bucket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆