The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

  • 1,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 1
  • Tình trạng: Còn hàng

I was stuck for 3 days and finally, after reading a ton of blogs and answers I was able to lớn configure Amazon AWS S3 Bucket.

On the AWS Side

I am assuming you have already

  1. Created an s3-bucket
  2. Created a user in IAM

Steps

  1. Configure CORS settings

    you bucket > permissions > CORS configuration

    
    
        *
        GET
        POST
        PUT
        *
    
    ```
    
    
  2. Generate A bucket policy

your bucket > permissions > bucket policy

It should be similar to lớn this one

 {
     "Version": "2012-10-17",
     "Id": "Policy1602480700663",
     "Statement": [
         {
             "Sid": "Stmt1602480694902",
             "Effect": "Allow",
             "Principal": "*",
             "Action": "s3:GetObject",
             "Resource": "arn:aws:s3:::harshit-portfolio-bucket/*"
         }
     ]
 }
PS: Bucket policy should say `public` after this 
  1. Configure Access Control List

your bucket > permissions > acces control list

give public access

PS: Access Control List should say public after this

  1. Unblock public Access

your bucket > permissions > Block Public Access

Edit and turn all options Off

**On a side note if you are working on django add the following lines to lớn you settings.py tệp tin of your project **

#S3 BUCKETS CONFIG

AWS_ACCESS_KEY_ID = '****not to lớn be shared*****'
AWS_SECRET_ACCESS_KEY = '*****not to lớn be shared******'
AWS_STORAGE_BUCKET_NAME = 'your-bucket-name'

AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

# look for files first in aws 
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

# In India these settings work
AWS_S3_REGION_NAME = "ap-south-1"
AWS_S3_SIGNATURE_VERSION = "s3v4"