Reputation: 403
I have a Django webapp that is hosted on Heroku. The site functions perfectly except or the image rendering. I am using AWS S3 buckets.
How my images currently look.
This is the output when right click and view image in a new tab
This XML file does not appear to have any style information associated with it. The document
tree is shown below.
<Error>
<Code>InvalidRequest</Code>
<Message>
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
</Message>
<RequestId>B965F49FC9AD8BD8</RequestId>
<HostId>
NyDkC2+pLPd/5tzWgJb+dEJOWu7eNCfbVyqLdZWOr1JyIFTe6rZ8BbRJHlbweCLU1MJ7xmlrxEM=
</HostId>
</Error>
Settings.py
import os
import django_heroku
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# (os.environ.get('DEBUG_VALUE') == 'True')
ALLOWED_HOSTS = ['xxx.herokuapp.com']
# Application definition
INSTALLED_APPS = [
'users.apps.UsersConfig',
'blog.apps.BlogConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cleanup',
'taggit',
'hitcount',
'storages',
]
***************
***************
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGIN_REDIRECT_URL = 'blog-home'
LOGIN_URL = 'login'
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
django_heroku.settings(locals())
I have no idea why it is doing this and have tried almost everything. I hope it is just a simple mistake!
Upvotes: 1
Views: 434
Reputation: 49
I got the same error.. like you said its very tiny detail..
-for the above error add the lines below to settings.py
AWS_S3_REGION_NAME = 'ap-south-1' #change to your region
AWS_S3_SIGNATURE_VERSION = 's3v4'
Cheers, have a great day!
Upvotes: 1