Aleksei Khatkevich
Aleksei Khatkevich

Reputation: 2197

Troubles using Amazon S3 with Europe based buckets in django-storages

Question is regarding Amazon S3 buckets in EU.

I have a Django project hosted locally and decided to store media files in Amazon S3 buckets. For doing this I use Django-storages app with the following settings in settings.py:

AWS_ACCESS_KEY_ID = "xxxxxxx"
AWS_SECRET_ACCESS_KEY = "xxxxxxxxxx"
AWS_STORAGE_BUCKET_NAME = 'hadcasetest'

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

MEDIA_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'


THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
THUMBNAIL_BASEDIR = "thumbnails"
THUMBNAIL_MEDIA_URL = MEDIA_URL

Well, it works when I use bucket from USA region and doesn't when I use buckets from Europe. I tried all possible locations in Europe – they all do not work.

Type of error I get: S3ResponseError: 400 Bad Request

Question is what should I change to get access via Django -storages to Europe based buckets to use them in Django app?

P.S. I can use AWS CLI to write in each buckets even in European ones but, Django-storages can not.

Should I obtain specific EU credentials perhaps?

Upvotes: 1

Views: 160

Answers (1)

Aleksei Khatkevich
Aleksei Khatkevich

Reputation: 2197

I added these parameters in settings.py and it helped:

AWS_S3_HOST = "s3.eu-central-1.amazonaws.com"
S3_USE_SIGV4 = True
AWS_S3_REGION_NAME = "eu-central-1"

Upvotes: 1

Related Questions