开发者

Strange Behavior with Carrierwave Url Generation

I'm stumped on this one. I'm using Carrierwave with Fog to handle thumbnail uploads for an app hosted on Heroku and the image urls don't seem to be generating properly.

I've tried setting up my config file three different ways:

CarrierWave.configure do |config|

  config.fog_credentials = {
     :provider => 'AWS',
     :aws_access_key_id => 'xxx',
     :aws_secret_access_key => 'yyy',
  }

  config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
end

makes the image urls work properly, but i can't save new images without getting an insane error in my logs (several hundred lines long, after saying the keys don't match.)

CarrierWave.configure do |config|

  config.fog_credentials = {
     :provider => 'AWS',
     :aws_access_key_id => 'xxx',
     :aws_secret_access_key => 'yyy',
  }

开发者_StackOverflow中文版  config.fog_directory = 'statics.gallery.spongecell.com'
  config.fog_host = 'https://s3.amazonaws.com/'

end

makes uploads work, but not images! THe bucket name is missing from the image url: http://s3.amasonaws.com//uploads/blah/etc

And weirdest of all:

CarrierWave.configure do |config|

  config.fog_credentials = {
     :provider => 'AWS',
     :aws_access_key_id => 'xxx',
     :aws_secret_access_key => 'yyy',
  }

  config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
  config.fog_public = false
end

makes both work but the image urls are appended with the s3 secret keys (bad!) and it's very slow. Any idea what's possibly happening here?

Thanks in advance!


I don't think you should need to set fog_host at all (if you leave it blank and just set fog_directory I think you should get what you want). If you set fog_public=false, the extra stuff will be a signature generated utilizing your secret key, but it shouldn't actually contain any secrets (this is how S3 allows you to temporarily provide access to something which is normally private). Hope that helps/clarifies.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜