python - boto s3 Bucket 与 get_bucket

标签 python amazon-s3 boto

我尝试访问存储桶内的 key ,尽管我有该 key 的权限,但我没有该权限。 为了能够执行 get_key('this/is/my_key'),我需要存储桶对象:

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我只看到验证检查。还有什么吗?

最佳答案

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

关于python - boto s3 Bucket 与 get_bucket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42717551/

相关文章:

python - 使用 boto 从 Google App Engine 连接到 Route53 API

python - 如何在 PyCharm 中查找已知 Python 对象的类定义?

用于打印的 Python 字典键格式不适用于数字字符串

python - tf.data.Dataset 对象作为 tf.Keras 模型的输入 -- ValueError

python - 在没有 '-it' 的情况下运行容器时只出现一行 SimpleHTTPServer 输出

java - AWS S3 Java : doesObjectExist results in 403: FORBIDDEN

python - 使用 Python Boto 以编程方式启动新的 EC2 实例

python - 网络爬虫问题 : IndexError: string index out of range

mysql - 我们可以将 SQL 从 S3 存储桶导入到 AWS ec2(实例)吗?

amazon-web-services - 如何从S3中的zip存档中提取文件