Full list of changes for migrating Carrierwave from file to fog
Notes from when we switched from file to object storage:
- In the uploaders
storage :file
should be changed tostorage fog
. Set development to file:
if Rails.env.development?
storage :file
else
storage :fog
end
- Add the fog config to an initializer:
CarrierWave.configure do |config|
config.fog_directory = ENV['FOG_DIRECTORY']
config.asset_host = ENV['FOG_ASSET_HOST']
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['FOG_ASSET_KEY'],
aws_secret_access_key: ENV['FOG_ASSET_SECRET'],
region: ENV['FOG_ASSET_REGION'],
endpoint: ENV['FOG_ASSET_ENDPOINT']
}
config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' }
end
-
Any place where
file.file
is used, for example if there was asend_data
should be changed toopen(@model.image_url, 'rb') do |file|
-
file.original_filename
should be changed tofile.filename