【问题标题】:Connecting to S3 using Boto - No handler was ready to authenticate使用 Boto 连接到 S3 - 没有处理程序准备好进行身份验证
【发布时间】:2013-07-29 03:24:46
【问题描述】:

我正在Heroku 上设置一个 Django 应用程序,并希望将媒体文件存储在 S3 上。我正在使用Python's Boto module 并继续遇到同样的错误:

错误:

No handler was ready to authenticate. 
1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

我已尝试保存我的凭据

(a) 在我的Heroku config file 中使用os.environ['AWS_ACCESS_KEY_ID]

(b) 在我的settings.py 文件中和

(c) 根据文档在单独的 .boto 文件中。

这是我的 settings.py 的相关部分,文件本身包含凭据:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': "os.path.join(BASE_DIR, 'db.sqlite3')",   # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

#config for S3
DATABASES['default'] =  dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

S3_BUCKET_NAME = 'companylistings'
#AWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxxxx'
#AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxxxx'
#STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'http://s3.amazonaws.com/%s' %S3_BUCKET_NAME


MEDIA_ROOT = '/media/'
MEDIA_URL = S3_URL + MEDIA_ROOT

STATIC_ROOT = '/static/'
STATIC_URL = S3_URL + STATIC_ROOT

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

【问题讨论】:

标签: python django heroku boto


【解决方案1】:

检查您的存储桶设置:

S3_BUCKET_NAME

我的工作配置是:

AWS_STORAGE_BUCKET_NAME

试试这个!

我的完整配置是:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'PRIVATE'
AWS_SECRET_ACCESS_KEY = 'PRIVATE'
AWS_STORAGE_BUCKET_NAME = 'PRIVATE'

【讨论】:

    【解决方案2】:

    如果是在 Windows 上,请按照以下步骤操作:

    安装:pip install awscli

    打开 cmd 并输入:

    $ aws configure
    AWS Access Key ID: 'your Access Key ID'
    AWS Secret Access Key: 'your Secret Access Key'
    Default region name: us-east-1
    Default output format: json
    
    $ manage.py shell
    >>import boto
    >>s3 = boto.connect_s3()
    

    没有显示错误消息。完成了

    详情:http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration

    【讨论】:

      猜你喜欢
      • 2011-07-20
      • 2012-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      相关资源
      最近更新 更多