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

前端 未结 20 1228
既然无缘
既然无缘 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:02

    Code for Flask (boto3)

    Don't forget to import Config. Also If you have your own config class, then change its name.

    from botocore.client import Config
    
    s3 = boto3.client('s3',config=Config(signature_version='s3v4'),region_name=app.config["AWS_REGION"],aws_access_key_id=app.config['AWS_ACCESS_KEY'], aws_secret_access_key=app.config['AWS_SECRET_KEY'])
    s3.upload_fileobj(file,app.config["AWS_BUCKET_NAME"],file.filename)
    url = s3.generate_presigned_url('get_object', Params = {'Bucket':app.config["AWS_BUCKET_NAME"] , 'Key': file.filename}, ExpiresIn = 10000)
    

提交回复
热议问题