为什么即使我公开了这个存储桶,来自Amazon S3的图像网址也有AWSaccesskey和expiration?

时间:2015-06-16 15:55:49

标签: ruby-on-rails amazon-s3 carrierwave

以下是我添加的政策:

{
  "Version": "2012-10-17",
  "Statement": [
    {
        "Sid": "MakeItPublic",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::bucketname/*"
    }
  ]
}

我创建了一个IAM并将AmazonS3FullAccess附加到该IAM。

在我的rails应用程序中,我显示如下图片:

- @pictures.each do |picture|
  %img{src: picture.image_url}

,生成的网址如下:

https://leaguedraw.s3-us-west-2.amazonaws.com/uploads/73dfe6c6-0c25-496c-be9f-6f2beb75d7c3.png?AWSAccessKeyId=myaccesskey&Expires=1434472944&Signature=d1vIYOQt410%2BgcXs6%2BATSCsG2Mk%3D

当我想要这个时:

https://leaguedraw.s3-us-west-2.amazonaws.com/uploads/73dfe6c6-0c25-496c-be9f-6f2beb75d7c3.png

我还需要做些什么才能生成后一个网址?

其他信息:使用carrierwave gem和carrierwave-aws gem

1 个答案:

答案 0 :(得分:0)

原来我需要从

更改配置文件中的acl
config.aws_acl = :'public-read'

config.aws_acl = :public_read

即使文档说要使用:'public-read'