1 건의
S3 검색결과
  1. 2016.05.25 꼬마군단

GemFile


gem 'carrierwave'

gem 'fog'




config/initializers/carrierwave.rb

CarrierWave.configure do |config|
 
  config.fog_credentials = {
    provider:              'AWS',                        # required
    aws_access_key_id:     'ACCESS_KEY',                        # required
    aws_secret_access_key: 'SECRET_KEY',                        # required
    region:                'ap-northeast-1'                  # optional, defaults to 'us-east-1'
 
  }
  config.fog_directory  = 'PRODUCTION_BUCKET' if Rails.env.production?                         # required
  config.fog_directory  = 'DEVELOPMENT_BUCKET' if !Rails.env.production?                          # required
  config.fog_public     = true # optional, defaults to true
  config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" } # optional, defaults to {}
end




app/uploader/image_uploader.rb


class ImageUploader < CarrierWave::Uploader::Base
   
  
  storage :fog
 
  def store_dir
    "content/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

 def extension_white_list
    %w(jpg jpeg gif png)
  end

end




app/model/image_model.rb

 class ImageModel < ActiveRecord::Base

     mount_uploader :image, ImageUploader
  
  end
 



TokenMarket ICO calendar
태그