所有RubyGems的版本。我正在使用Ruby on Rails 3.1.3,Ruby 1.9.2,CarrierWave 0.5.8和Fog 1.1.2。Fog和Amazon S3的公開URL
我正在使用CarrierWave RubyGem進行圖片上傳,並使用紅寶石文件上傳的Amazon S3文件上傳。
在我CarrierWave初始化文件,我有:
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: 'xxx',
aws_secret_access_key: 'xxx'
}
if Rails.env.production?
config.fog_directory = 'bucket1'
elsif Rails.env.development?
config.fog_directory = 'bucket2'
else
config.fog_directory = 'bucket3'
end
config.fog_public = false
config.fog_authenticated_url_expiration = 60
end
我有一個上傳文件:
class PageAttachmentUploader < CarrierWave::Uploader::Base
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.development? || Rails.env.production?
config.fog_public = true
end
end
storage :fog
end
我有兩個上傳文件
。我想要一個被設置爲私人,一個被設置爲公共。
我試圖覆蓋CarrierWave配置當PageAttachmentUploader被調用並將URL設置爲公共。這在本地機器中很有魅力,但不適用於舞臺,沙盒和製作。
我更改了CarrierWave intializer中的config.fog_public = true。即使這在沙箱中也不起作用。我該如何解決這個問題?
是的,多數民衆贊成在正確的! fog_public:在上傳文件中爲我工作。謝謝! – user1286523 2012-03-23 14:30:21
好吧,然後不要忘記投票這個答案:)! – 2012-03-23 17:25:28
沒有爲我工作 – 2016-09-19 17:38:29