Tôi đang cố gắng tìm ra cách thiết lập CarrierWave để làm việc với Fog và Amazon S3. Trên S3, tôi có một thùng, "bucket1" với thư mục "hình ảnh". Tải lên hoạt động tốt. Ví dụ: hình ảnh có thể được tải lên biểu mẫu nào đó ở dạng https://s3.amazonaws.com/bucket1/images/picture/pic1.jpg. Tuy nhiên, trong chế độ hiển thị, khi tôi gọi trình trợ giúp image_url, tôi nhận được https://s3.amazonaws.com/images/picture/pic1.jpg. Tôi đang thiếu gì ở đây?CarrierWave và Fog, S3 bucket và cấu hình store_dir
#config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'aws_key',
:aws_secret_access_key => 'aws_secret'
}
config.fog_directory = 'bucket1'
config.fog_host = 'https://s3.amazonaws.com'
config.fog_public = true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
end
#app/uploader/image_uploader.rb
def store_dir
"images/#{model.class.to_s.underscore}"
end
#app/views/pictures/show.html.erb
<%= image_tag @picture.image_url if @picture.image? %>
được bạn lưu trữ nó trên Heroku? – noob
Tôi đang lưu trữ nó thông qua HostGator (dev) & EC2 (prod) –