Skip to content Skip to sidebar Skip to footer

Error Uploading To A Non-us Standard Aws S3 Bucket In Django Application; Us Standard Bucket Works Perfectly

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 fo

Solution 1:

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, LocationDEFAULT_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 = FalseAWS_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.

Solution 2:

"Singapore" is not a valid "region" in the sense that you need, here:

AWS_S3_REGION = 'ap-southeast-1'

http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

This may not be the only issue, but it should be one of the issues, at least.

Solution 3:

AWS_AUTO_CREATE_BUCKET = TrueAWS_S3_HOST = 's3-eu-west-1.amazonaws.com'

This works also for django-storages. Thanks @gmcc051

Post a Comment for "Error Uploading To A Non-us Standard Aws S3 Bucket In Django Application; Us Standard Bucket Works Perfectly"