-1

I have a problem when I upload an image in carrierwave uploader

This is config/initailizers/fog.rb:

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider              => 'AWS',
    :aws_access_key_id     => '<redacted>',
    :aws_secret_access_key => '<redacted>'
    }

    config.fog_directory = 'illusioncalendar'
    config.cache_dir = "#{Rails.root}/tmp/uploads"  
    config.fog_public = false 
    end

and this is app/uploaders/avatar_uploader.rb:

class AvatarUploader < CarrierWave::Uploader::Base
   include CarrierWave::MiniMagick
   storage :fog

  def store_dir
    "illusioncalendar/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def default_url
      ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
     "/images/fallback/" + [version_name, "default.png"].compact.join('_')
   end
  process :scale => [200, 300]

  version :thumb do
    process :scale => [200, 200]
  end

  version :small do
    process :scale => [48, 48]
  end

   def extension_white_list
     %w(jpg jpeg gif png)
   end
   def cache_dir
    "#{Rails.root}/tmp/uploads"
  end

end

And I have a mistake, when storage is fog, in file, i ran this successfully. Thanks for any help. Regards!

Vitalii
  • 1,137
  • 14
  • 25

1 Answers1

1

There could be other issues as well (we can't tell without the exact error or trace), but until then:

  1. I don't know if this is a typo in your code or in your copypasta, but you're missing a comma after your aws_secret_access_key.

  2. fog_directory shouldn't end in a slash.

Taavo
  • 2,406
  • 1
  • 17
  • 17