我正在Heroku上设置一个 Django 应用程序,并希望将媒体文件存储在 S3 上。我正在使用Python 的 Boto 模块并继续遇到相同的错误:
错误:
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'),
)