gpt4 book ai didi

ruby-on-rails - Rails 回形针错误 `AWS::S3::Errors::BadRequest` 在 `exists?` 和 `clear`

转载 作者:行者123 更新时间:2023-12-04 08:55:12 25 4
gpt4 key购买 nike

全部。

我一切正常:图像正在上传,可以通过 Web 使用回形针和 S3 访问,除非我登录 rails c并输入如下内容:

> User.first.avatar.exists?
[AWS S3 400 0.093287 0 retries] head_object(:bucket_name=>"mozg-staging-static",:key=>"users/avatars/000/000/001/original/289736.jpg") AWS::S3::Errors::BadRequest AWS::S3::Errors::BadRequest

=> false

clear 相同方法。还没有找到解决办法。

我有这个许可政策:
    {
"Sid": "Stmt1436958517000",
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListBucketVersions",
"s3:ListMultipartUploadParts",
"s3:ListObjects",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:PutObjectVersionAcl",
"s3:RestoreObject"
],
"Resource": [
"arn:aws:s3:::mozg-staging-static",
"arn:aws:s3:::mozg-staging-static/*"
]
}

谢谢你的支持。

最佳答案

这可能是您的政策有问题,您可以尝试:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": ["arn:aws:s3:::mozg-staging-static"]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": ["arn:aws:s3:::mozg-staging-static/*"]
}
]
}
ListBucket action 需要设置在bucket级别,而 PutObject , GetObjectDeleteObject需要针对存储桶中的对象进行设置。我省略了其他操作以保持答案简短。如果需要,您当然需要重新添加它们。您可以在此处找到操作列表以及它们是存储桶操作还是对象操作: http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html

关于ruby-on-rails - Rails 回形针错误 `AWS::S3::Errors::BadRequest` 在 `exists?` 和 `clear`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31435435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com