1

我正在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'),
)
4

2 回答 2

0

检查您拥有的存储桶设置:

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'
于 2013-07-29T13:51:01.633 回答
0

如果它在 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

于 2015-10-04T10:44:00.990 回答