使用Papreclip的Rails 4 S3错误:NoSuchKey没有这样的密钥

时间:2015-12-13 05:26:16

标签: ruby-on-rails-4 amazon-web-services amazon-s3 paperclip

我试图确定在尝试使用Paperclip上传文件到S3时出现此错误的原因:

[AWS S3 404 0.994093 1 retries] head_object(:bucket_name=>"mybucketname",:key=>"development/images/26/original/picture") AWS::S3::Errors::NoSuchKey No Such Key

s3.yml

development:
  access_key_id: "xxxxxx"
  secret_access_key: "xxxxxx"

production:
  access_key_id: "xxxxxx"
  secret_access_key: "xxxxxx"

development.rb

 config.paperclip_defaults = {
  :storage => :s3,
  :bucket => 'mybucketname'
  }

user.rb

has_attached_file :image,
  :storage => :s3,
    :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
    :s3_protocol => 'https',
    :path => ":rails_env/:attachment/:id/:style/:filename",
    :bucket => "mybucketname",
    styles: { 
      medium: "300x300>", 
      thumb: "100x100>" } 

的Gemfile

gem "paperclip", "~> 4.3"
gem 'aws-sdk-v1'

我已尝试删除paths3_protocol,但我收到了类似的错误。

我尝试将访问密钥移动到development.rb。此外,我已临时设置存储桶权限以允许每个人上传。

1 个答案:

答案 0 :(得分:0)

我找到了答案here。在设置我的存储桶时,我没有设置我的安全策略。