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

前端 未结 20 1552
既然无缘
既然无缘 2020-11-22 14:19

I get an error AWS::S3::Errors::InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. when I try upload fi

20条回答
  •  一生所求
    2020-11-22 15:11

    I was stuck for 3 days and finally, after reading a ton of blogs and answers I was able to 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 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 you settings.py file of your project **

    #S3 BUCKETS CONFIG
    
    AWS_ACCESS_KEY_ID = '****not to be shared*****'
    AWS_SECRET_ACCESS_KEY = '*****not to 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"
    
    

提交回复
热议问题