0

These are my s3 configuration.

DEFAULT_FILE_STORAGE = 'doctocliq.utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'doctocliq.utils.StaticRootS3BotoStorage'
AWS_STORAGE_BUCKET_NAME = 'doctocliq'
S3DIRECT_REGION = 'us-west-2'
S3_URL = '//%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
MEDIA_URL = '//%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAME
MEDIA_ROOT = MEDIA_URL
STATIC_URL = S3_URL + 'static/'
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

Uploaded all the static files to the bucket with collectstatic command, except images all the other static files are working, on local server there is no issue also. The site link is http://doctocliq-dev.us-west-2.elasticbeanstalk.com/. Hope some body can help me, thank you.

bmons
  • 3,352
  • 2
  • 10
  • 18

1 Answers1

0

The S3_URl should be:

//s3-${AWS::Region}.amazonaws.com/% AWS_STORAGE_BUCKET_NAME

As there is no region mentioned in the URL the object is not getting located. This is needed especially when the bucket is NOT in N. Virginia region.

Also, refer for SuspiciousOperation:

"Suspicious Operation" calling static files from Amazon S3

Django amazon s3 SuspiciousOperation

ExploringApple
  • 1,348
  • 2
  • 17
  • 30
  • i have added as you mentioned, but didn't make any difference. – bmons Dec 11 '17 at 17:56
  • Is it adding the aws region in image url? – ExploringApple Dec 12 '17 at 11:22
  • this error is only for some images, some them are visible, so when i change the debug to true, the error message is SuspiciousOperation at /registrar-doctor/ Attempted access to '/images/backgrounds/doctablet.png' denied. – bmons Dec 14 '17 at 09:45