在django-storages中将Amazon S3与基于欧洲的存储桶一起使用时遇到的麻烦 [英] Troubles using Amazon S3 with Europe based buckets in django-storages
问题描述
有关欧盟的Amazon S3存储桶的问题.
Question is regarding Amazon S3 buckets in EU.
我在本地托管了一个Django项目,并决定将媒体文件存储在Amazon S3存储桶中.为此,我将Django-storages应用程序与 settings.py
中的以下设置配合使用:
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.
我得到的错误类型: S3ResponseError:400错误的请求
问题是我应该如何更改才能通过Django -storages访问基于欧洲的存储桶,以便在Django应用中使用它们?
Question is what should I change to get access via Django -storages to Europe based buckets to use them in Django app?
P.S.我可以使用AWS CLI在每个存储桶中进行写操作,即使是在欧洲存储桶中也可以,但是Django存储不能.
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?
推荐答案
我在settings.py中添加了这些参数,它有帮助:
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"
这篇关于在django-storages中将Amazon S3与基于欧洲的存储桶一起使用时遇到的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!