The default configuration won't work out of the box for Heroku, because the platform doesn't allow saving files to the filesystem (although it does use tempfiles).
Assuming you have an S3 account set up...
- fog - dragonfly
Initializer (e.g. config/initializers/dragonfly.rb in Rails):
require 'dragonfly' app = Dragonfly[:images] app.configure_with(:imagemagick) app.configure_with(:rails) if Rails.env.production? app.configure do |c| c.datastore = Dragonfly::DataStorage::S3DataStore.new( :bucket_name => 'my-bucket-name', :access_key_id => ENV['S3_KEY'], :secret_access_key => ENV['S3_SECRET'] ) end end app.define_macro(ActiveRecord::Base, :image_accessor)
The datastore remains as thefor non-production environments.
application.rb if using with Rails:
config.middleware.insert 1, 'Dragonfly::Middleware', :images
We don't store the S3 access key and secret in the repository, rather we use Heroku's config variables using the command line (we only have to do this once).
From your app's directory:
heroku config:add S3_KEY=XXXXXXXXX S3_SECRET=XXXXXXXXXX
Replace 'XXXXXXXXX' with your access key and secret.
If this is an issue, you may want to look into storing thumbnails on S3 (see ServingRemotely), or maybe generating thumbnails on upload (see Models), or maybe an after-deploy hook for hitting specific Dragonfly urls you want to cache, etc. It won't be a problem for most sites though.