Amazon S3 to store Wagtail media files - server 500 error on Heroku only

可紊 提交于 2019-12-08 05:55:21

问题


I have been following the Using Amazon S3 to Store Wagtail Media Files blog post to set up amazon s3 to store my wagtail media files

This works perfectly on my local development sever (all of the images appear in the S3 bucket as expected). However in deployment on Heroku I get a server 500 error just as the uploader completes and the images are not saved in the S3 bucket. There is no detail in the heroku logs other than this line. Which makes it very difficult to debug. I am not using S3 for my static assets (these are handled by whitenoise. Changing debug to True makes no difference. Any advice greatly appreciated.

2018-08-19T16:56:43.517786+00:00 app[web.1]: 10.7.223.133 - - [19/Aug/2018:16:56:43 +0000] "POST /admin/images/multiple/add/ HTTP/1.1" 500 363 "https://isawebsite.herokuapp.com/admin/images/multiple/add/

github repo

Update: by trying image upload via the django-admin interface rather than wagtail uploader I got a more informative error message. An error occurred (InvalidAccessKeyId) when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records. I don't understand this because the keys are definitely correct in my .env file and are pushed to heroku config. The keys work locally and in AWS CLI.


回答1:


We worked this out - the config values in Heroku for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY included surrounding quotes, e.g. 'QWERTY12345' rather than QWERTY12345. It worked locally because python-dotenv strips surrounding quotes from .env files:

https://github.com/theskumar/python-dotenv/blob/master/dotenv/main.py#L43

I've updated the blog post at https://wagtail.io/blog/amazon-s3-for-media-files/ to clarify this.



来源:https://stackoverflow.com/questions/51920001/amazon-s3-to-store-wagtail-media-files-server-500-error-on-heroku-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!