Skip to content

Instantly share code, notes, and snippets.

@hiroism007
Last active December 15, 2015 15:09
Show Gist options
  • Save hiroism007/5279795 to your computer and use it in GitHub Desktop.
Save hiroism007/5279795 to your computer and use it in GitHub Desktop.
amazonS3 + fog + carrierwave, fileupload setting.
CarrierWave.configure do |config|
config.fog_credentials =
:provider => 'AWS',
:aws_access_key_id => ENV["AWS_S3_KEY_ID"],
:aws_secret_access_key => ENV["AWS_S3_SECRET_KEY"]
}
config.fog_directory = ENV["AWS_S3_BUCKET"]
end
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage Rails.env.production? ? :fog : :file
def cache_dir
"#{Rails.root}/tmp/uploads"
end
version :thumb do
process :resize_to_limit => [200, 200]
end
version :icon do
process :resize_to_fill => [64,64]
end
version :small_icon do
process :resize_to_fill => [32,32]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment