سؤال

I'm getting an Access Denied error with Amazon S3 and can't figure out why.

My settings are as follows:

STATIC_URL = 'http://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME

What would cause an access denied error? I have verified that my keys are correct.

هل كانت مفيدة؟

المحلول

The URL you show above would resolve to a bucket within S3. In order to access that bucket successfully with such a URL, the permissions on the bucket would have to grant 'public-read' access to the bucket. In addition, each object or file within the bucket would have to grant 'public-read' access, as well.

Do you want the bucket and all content within the bucket to be readable by anyone? If so, make sure the permissions are set appropriately. Note, however, that granting 'public-read' to the bucket itself will allow anyone to list the contents of the bucket. That's usually unnecessary and probably should be avoided.

Also note that the keys (I assume you mean your AWS access key and secret key) only apply when you are accessing S3 via the API. If you simply access it with the URL via a browser, the credentials are not used in the request.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top