Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku and carrierwave don't load my s3 configuration

I have an application on Heroku that uses the Carrierwave gem to upload images to S3.

I have set the s3 configuration in an initializer called carrierwave.rb

CarrierWave.configure do |config|
  config.s3_access_key_id = 'XXXXXXXXXXXXXXXXXXXX'
  config.s3_secret_access_key = 'XXXXXXXXXXXXXXXXX'
  config.s3_bucket = 'XXXXX'
  config.storage = :s3
end

This works fine in development on my local machine, however once I deploy to Heroku I get the following error

A Errno::EACCES occurred in events#update:

Permission denied - /app/public/uploads
/usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:243:in `mkdir'

Obviously it's trying to write to the heroku server which is read only and not picking up my s3 settings.

Does anyone know how I can get heroku to send my files to s3?

like image 662
sk87 Avatar asked Dec 05 '25 16:12

sk87


1 Answers

From CarrierWave wikki:

Heroku has a read-only filesystem, so uploads must be stored on S3 and cannot be cached in the public directory.

You can work around this by setting the cache_dir in your Uploader classes to the tmp directory:

Check out https://github.com/jnicklas/carrierwave/wiki and scroll to the bottom section labeled "CarrierWave on Heroku" to see how they set this up. Hope this helps someone.

like image 128
John Goodman Avatar answered Dec 08 '25 13:12

John Goodman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!