EXCON ::错误::故宫(预期(200)LT; =>实际(403禁止) [英] Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)

查看:233
本文介绍了EXCON ::错误::故宫(预期(200)LT; =>实际(403禁止)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将图片上传到了汽车的对象,我拒绝访问S3。但该网站的图像,是在资产的文件夹都显示出来,因为我加入S3就好了。特定的错误,我得到的是这样的:

When I try to upload a picture to a "Car" object I'm denied access to S3. But the site images that are in the assets folder have displayed just fine since I added S3. The specific error that I get is this:

2015-02-17T14:40:48.459629+00:00 app[web.1]: Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)
2015-02-17T14:40:48.459630+00:00 app[web.1]: excon.error.response
2015-02-17T14:40:48.459635+00:00 app[web.1]:     "Connection"       => "close"
2015-02-17T14:40:48.459637+00:00 app[web.1]:     "Content-Type"     => "application/xml"
2015-02-17T14:40:48.459639+00:00 app[web.1]:     "Date"             => "Tue, 17 Feb 2015 14:40:48 GMT"
2015-02-17T14:40:48.459640+00:00 app[web.1]:     "Server"           => "AmazonS3"
2015-02-17T14:40:48.459632+00:00 app[web.1]:   :body          => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>2CE306ACD51F02A1</RequestId><HostId>tKLXUAKxyDFTMExl7kE+AuVVsEJOFqXh983li6N7R2UlYDXv1Z3GJRvW5zy1XIXVs2zArp310vg=</HostId></Error>"
2015-02-17T14:40:48.459642+00:00 app[web.1]:     "x-amz-id-2"       => ""part of secret key"="

通过密钥的一部分,显然节录。我试图创造一个不同的用户,并使用新的密钥,但是这并没有奏效。不到哪去从这里开始。

With "part of secret key" obviously redacted. I've tried creating a different user and using new keys, but that hasn't worked. Not where to go from here.

应用/上传者/ picture_uploader

class PictureUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  process resize_to_limit: [400, 400]

  if Rails.env.production?
    storage :fog
  else
    storage :file
  end

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  # Add a white list of extensions which are allowed to be uploaded.
  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

carrier_wave.rb

if Rails.env.production?
  CarrierWave.configure do |config|
    config.fog_credentials = {
      # Configuration for Amazon S3
      :provider              => 'AWS',
      :aws_access_key_id     => ENV['S3_ACCESS_KEY'],
      :aws_secret_access_key => ENV['S3_SECRET_KEY']
    }
    config.fog_directory     =  ENV['S3_BUCKET']
  end
end

我相信这是所有相关的文件,让我知道如果有更多的看到的。不知道如果在指定的区域或电力用户会有所帮助,似乎并不像它那样。

I believe that's all of the relevant files, let me know if there's more to see. Not sure if specifying a region or a power user would help, doesn't seem like it would.

推荐答案

我遇到了同样的错误,而解决办法是从连接AWS管理控制台的管理访问策略:

I was encountering the same error, and the solution was to attach administrative access policies from the AWS Management Console:

1)登录到AWS管理控制台在 http://aws.amazon.com/iam/

1) Sign in to the AWS Management Console at http://aws.amazon.com/iam/

2)单击策略从导航窗格左侧

2) Click "Policies" from the Navigation Pane on the left

3)选择AdministratorAccess政策

3) Select the "AdministratorAccess" policy

4)单击策略操作>附加在页面顶部

4) Click Policy Actions > Attach at the top of the page

5)选择与我的S3_ACCESS_KEY相关联的用户,S3_SECRET_KEY和S3_BUCKET

5) Select the user associated with my S3_ACCESS_KEY, S3_SECRET_KEY, and S3_BUCKET

6)单击连接策略

仅仅授予从我的水桶所有权限在 https://console.aws.amazon.com/s3/home是不够的。

Merely granting all permissions from my bucket at https://console.aws.amazon.com/s3/home was not sufficient.

这篇关于EXCON ::错误::故宫(预期(200)LT; =&GT;实际(403禁止)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆