python - 通过 boto 2.49 连接 AWS S3 时遇到问题
问题描述
以下代码适用于生产,但当我尝试在本地设置时失败。
默认主机设置为 s3.amazonaws.com。但是我得到 S3ResponseError: 403 Forbidden 无论我将 is_secure 设置为 True 还是 False 以及是否添加了 calling_format = boto.s3.connection.OrdinaryCallingFormat() 。
我尝试在我的 S3 存储桶上搜索,端点是http://bucket_name.s3-website-us-east-1.amazonaws.com。所以我通过环境变量将主机设置为 s3-website-us-east-1.amazonaws.com。而且我遇到了 SSLError 异常,无论 is_secure 是 True 还是 False,都会重新连接 call_format = boto.s3.connection.OrdinaryCallingFormat()。我也因为没有calling_format但将is_secure设置为True而遇到了同样的错误,而S3ResponseError: 404 Not Found因为没有calling_format并将is_secure设置为False。
原始代码没有 calling_format 和 is_secure 参数。这些是我在其他帖子中发现的。
import boto
import boto.s3.connection
c = boto.connect_s3(aws_access_key_id='********',
aws_secret_access_key='*********',
host=endpoint)
b = c.get_bucket(bucket_name)
解决方案
推荐阅读
- java - 使用 bean ref 在骆驼路线中设置标题
- php - 删除多维数组中的重复项
- c# - C#:FastColoredTextBox 不更新语法突出显示
- c++ - 在这种情况下显式调用时,std::cout 如何改变析构函数的行为?
- xml - Facebook Zapier 解析器 XML 提要
- clojure - Clojure 不知道如何创建 ISeq
- ruby-on-rails - 保持未经许可的参数不打印到日志
- amazon-web-services - 限制对特定 IAM 用户的 API 网关访问
- javascript - 如何将dom元素旋转一定量(纯js)
- google-sheets - 如何在 Google 表格中按 1 列自动排序