You got the following error while using your digital ocean spaces for static files:
<Error>
<Code>SignatureDoesNotMatch</Code>
<RequestId>xxxxx-716fe6ea-xxxx</RequestId>
<HostId>xxx-nyc3c-xxx-xxxx</HostId>
</Error>
GET 403
Forbidden
To fix this, you have to declare the region.
AWS_S3_REGION_NAME = "nyc3"
Your settings.py
file should mostly look as follows:
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID', 'DefaultAccessKey')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY', 'DefaultSecretKey')
AWS_STORAGE_BUCKET_NAME = os.getenv('AWS_STORAGE_BUCKET_NAME', 'DefaultBucketName')
AWS_S3_ENDPOINT_URL = os.getenv('AWS_S3_ENDPOINT_URL', 'DefaultEndpointUrl')
AWS_S3_OBJECT_PARAMETERS = {
"CacheControl": "max-age=86400",
# "ACL": "public-read" # THIS LINE IS OPTIONAL
}
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_DEFAULT_ACL = 'public-read'
AWS_LOCATION = 'static'
AWS_S3_REGION_NAME = "nyc3"
# Note: Used format method for the STATIC_URL to keep the code consistent
STATIC_URL = '{}/{}/'.format(AWS_S3_ENDPOINT_URL, AWS_LOCATION)
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]