I
I
iSpeedMan2020-06-07 17:39:39
Django
iSpeedMan, 2020-06-07 17:39:39

How to setup Django-Heroku-S3 connection?

Here is what is in the project settings, there is a Heroku-S3 connection, but when loading any media file, it gives an error "Required parameter name not set"

INSTALLED_APPS = [
...
'storages',
...
]

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': ******',
        'USER': ******'',
        'PASSWORD': '******'',
        'HOST': '******'',
        'PORT': '******',
        'URL': '******'',
    }
}

AWS_DEFAULT_ACL = None
AWS_ACCESS_KEY_ID = os.environ.get('**********')
AWS_SECRET_ACCESS_KEY = os.environ.get('**********')
AWS_STORAGE_BUCKET_NAME = os.environ.get('**********')
AWS_URL = os.environ.get('**********')
 
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'


STATIC_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"), 
]


AWS_MEDIA_URL = "{}/{}/".format(AWS_URL, AWS_STORAGE_BUCKET_NAME)
 
MEDIA_URL = AWS_MEDIA_URL

MEDIA_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'
MEDIA_ROOT = 'os.path.join(BASE_DIR, 'media')'  # Путь к медиа фаилам (для сервера)

ADMIN_MEDIA_PREFIX = '/media/admin/'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iSpeedMan, 2020-06-08
@iSpeedMan

There is progress, all statics and media are now uploaded to S3, paths to them are displayed on the site, but they are not uploaded to the site, and when I try to view the file, I get an error:
<Error>
<Code> InvalidRequest Code> The
authorization mechanism you provided is not supported. Please use AWS4-HMAC-SHA256. Message>
79A8BD36A292E003 RequestID>
XC3yCnKazFku58wRyWPIWH3ZH4LQXjh4uYFivE / LCnuCwhloPB5JryCWPgJCm1uO3IoHUa2L0Ks = HOSTID>
Error>
I don’t understand how to use this information, where to change these settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question