开发者

AWS::S3::MissingAccessKey in Paperclip but I've defined both

I'm on Heroku, and this is a portfolio thing which I'm putting up on github for potential employers to look at, so obviously I don't want to stick my keys in a S3.yml file. I've exported S3_KEY and S3_SECRET to my environment both on Heroku and my machine and ruby can access them. But when I try and upload, it gives me the following error:

AWS::S3::MissingAccessKey in Portfolio itemsController#update

You did not provide both required access keys. Please provide the access_key_id and the secret_access_key.

The trace is irrelevant except for my controller line #, which works fine until I try and upload a file. Here's what I have:

class Asset < ActiveRecord::Base
  attr_accessible :image, :image_file_name, :image_content_type, :image_file_size, :portfolio_item_id, :order
开发者_开发技巧
  has_attached_file :image,
    :styles => {
      :thumb => "100x100#",
      :small => "300x300",
      :large => "600x600>"
               },
    :storage => :s3,
    :s3_credentials => {
      :access_key_id => ENV["S3_KEY"],
      :secret_access_key => ENV["S3_SECRET"]
                       },
    :bucket => "bucketybucket",
    :path => "portfolio"

end

Anyone know what's going on here? How am I constructing this hash wrong?

Oh, and I've followed this thread, no dice: Paperclip and Amazon S3 Issue


same problem...

seems like that ENV const doesn't load before loading the module. solve by using file argument like this

:s3_credentials => Rails.root.join('config/amazon_s3.yml')

and in amazon_s3.yml

access_key_id: 'your_key'
secret_access_key: 'your_sec_key'
bucket: 'somebucket'

furthermore, you can set environment variable by using heroku config:add command, which is describe in Heroku DevCenter


The problem is because the Enviroment variable in heroku is different that the enviroment variable in your system, so it may happen that the application works just in one enviroment

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜