admin管理员组文章数量:1194969
def get_presigned_url(self, expiration=3600):
s3_client = boto3.client(
's3',
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
region_name=settings.AWS_REGION_NAME,
config=Config(signature_version='s3v4')
)
from urllib.parse import quote
key = f"media/{quote(self.file.name)}"
presigned_url = s3_client.generate_presigned_url(
'put_object',
Params={'Bucket': settings.BUCKET_NAME, 'Key': key},
ExpiresIn=expiration,
)
return presigned_url
I am currently generating the presigned_url
, and when I try to access it, I receive
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your key and signing method.
In order to check that my ACCESS_KEY
and SECRET_ACCESS_KEY
, I tried to login to AWS CLI, and then I've done this:
Entered CLI, and wrote the exact ACCESS_KEY
and SECRET_ACCESS_KEY
that I am using in the code.
echo "test content" > test-file.txt
aws s3 cp test-file.txt s3://bucket_name/test-file.txt --profile my-profile
and it was successful (I was able to see it in the bucket):
upload: ./test-file.txt to s3://bucket_name/test-file.txt
I added access to the bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucket_name/*"
}
]
}
For the user, I gave the full access to S3, just in case.
After all these attempts, I still receive :
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your key and signing method.
版权声明:本文标题:amazon s3 - AWS-S3: The request signature we calculated does not match the signature you provided - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738507545a2090616.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论