I set up an S3 bucket in a non-US region (Singapore). When I try to upload images to it, I get a 301 (Permanently moved) error from S3. Researching has led me to understand that for a non-standard bucket, one must specify the particular endpoint and region.
I've tried a variety of configuration variables in my settings.py, but it never works. Note that boto and django-storages are installed, and I've gotten it to work for a US standard bucket before.
The following is how it's currently set up (plus all the different variations I've tried):
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_S3_FORCE_HTTP_URL = True
AWS_S3_SECURE_URLS = False
AWS_S3_URL_PROTOCOL = 'http'
AWS_QUERYSTRING_AUTH = False
AWS_SECRET_ACCESS_KEY = os.environ.get('awssecretkey')
AWS_ACCESS_KEY_ID = os.environ.get('awsaccesskeyid')
AWS_STORAGE_BUCKET_NAME = 'bucket.my'
#AWS_ENDPOINT = 's3-ap-southeast-1.amazonaws.com'
#AWS_S3_REGION = 's3-ap-southeast-1'
#REGION = 's3-ap-southeast-1'
#AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
#BOTO_S3_HOST = 'bucket.my.s3-ap-southeast-1.amazonaws.com'
#S3_HOST = 'http://bucket.my.ap-southeast-1.amazonaws.com'
#BOTO_BUCKET_LOCATION = 'Singapore'
#S3Connection.DefaultHost = 's3-ap-northeast-1.amazonaws.com'
#HOST = 'http://bucket.my.ap-southeast-1.amazonaws.com'
I'm using the current version of django-storages-redux and had to use the following in settings.py in order to use the Sydney S3 region.
import boto from boto.s3.connection import OrdinaryCallingFormat, Location DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = 'XXX' AWS_SECRET_ACCESS_KEY = 'XXX' AWS_STORAGE_BUCKET_NAME = 'my.bucket.name' AWS_AUTO_CREATE_BUCKET = False AWS_S3_HOST = 's3-ap-southeast-2.amazonaws.com' AWS_S3_CALLING_FORMAT = 'boto.s3.connection.OrdinaryCallingFormat'
Note the AWS_S3_HOST value; that is the parameter that I needed to solve the "301 (Permanently moved)" error.