Ognjen Regoje bio photo

Ognjen Regoje
But you can call me Oggy


I make things that run on the web (mostly).
More ABOUT me and my PROJECTS.

me@ognjen.io LinkedIn

Full list of changes for migrating Carrierwave from file to fog

#technical

Notes from when we switched from file to object storage:

  • In the uploaders storage :file should be changed to storage 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 a send_data should be changed to open(@model.image_url, 'rb') do |file|

  • file.original_filename should be changed to file.filename