django 存储 AWS S3 SigVer4:SignatureDoesNotMatch
django storages AWS S3 SigVer4: SignatureDoesNotMatch
我的配置(非常基础):
settings.py
AWS_S3_REGION_NAME = 'eu-west-3'
AWS_S3_FILE_OVERWRITE = False
# S3_USE_SIGV4 = True # if used, nothing changes
# AWS_S3_SIGNATURE_VERSION = "s3v4" # if used, nothing changes
AWS_ACCESS_KEY_ID = "xxx"
AWS_SECRET_ACCESS_KEY = "xxx"
AWS_STORAGE_BUCKET_NAME = 'xxx'
# AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com' # if used, no pre-signed urls
AWS_DEFAULT_ACL = 'private'
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
AWS_LOCATION = 'xxx'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
INSTALLED_APPS = [
...,
'storages'
]
models.py
class ProcessStep(models.Model):
icon = models.FileField(upload_to="photos/process_icons/")
我得到的:
- 预签名 url 已生成(在
icon.url
和管理页面上自动生成)
- 预签名url响应状态代码=403(禁止)
- 如果打开,
SignatureDoesNotMatch
错误。带文字:The request signature we calculated does not match the signature you provided. Check your key and signing method.
尝试过:
- 更改访问密钥(root 和 IAM)
- 更改存储桶区域
- 为
icon
字段创建单独的存储对象(同样的错误 SignatureDoesNotMatch)
- 更改 django-storages 包版本(目前使用最新的 1.11.1)
意见:
- boto3 客户端
generate_presigned_url
returns url 签名无效
问题:
- 我该怎么办?
- 为什么我会收到错误消息?
耐心是一种美德!
一个人可能需要等待 1 天才能正常工作
我的配置(非常基础):
settings.py AWS_S3_REGION_NAME = 'eu-west-3' AWS_S3_FILE_OVERWRITE = False # S3_USE_SIGV4 = True # if used, nothing changes # AWS_S3_SIGNATURE_VERSION = "s3v4" # if used, nothing changes AWS_ACCESS_KEY_ID = "xxx" AWS_SECRET_ACCESS_KEY = "xxx" AWS_STORAGE_BUCKET_NAME = 'xxx' # AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com' # if used, no pre-signed urls AWS_DEFAULT_ACL = 'private' AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'} AWS_LOCATION = 'xxx' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' INSTALLED_APPS = [ ..., 'storages' ] models.py class ProcessStep(models.Model): icon = models.FileField(upload_to="photos/process_icons/")
我得到的:
- 预签名 url 已生成(在
icon.url
和管理页面上自动生成) - 预签名url响应状态代码=403(禁止)
- 如果打开,
SignatureDoesNotMatch
错误。带文字:The request signature we calculated does not match the signature you provided. Check your key and signing method.
尝试过:
- 更改访问密钥(root 和 IAM)
- 更改存储桶区域
- 为
icon
字段创建单独的存储对象(同样的错误 SignatureDoesNotMatch) - 更改 django-storages 包版本(目前使用最新的 1.11.1)
意见:
- boto3 客户端
generate_presigned_url
returns url 签名无效
问题:
- 我该怎么办?
- 为什么我会收到错误消息?
耐心是一种美德!
一个人可能需要等待 1 天才能正常工作