123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- class FileUploader < CarrierWave::Uploader::Base
-
-
- include CarrierWave::MiniMagick
- include CarrierWave::MimeTypes
-
- include ::CarrierWave::Backgrounder::Delay
-
-
- if Rails.env.test? or Rails.env.cucumber?
- storage :file
- end
- if Rails.env.development?
- storage :file
- end
- if Rails.env.production?
-
-
- include Sprockets::Helpers
- storage :fog
- end
-
-
- def store_dir
- "uploads/#{mounted_as}/#{model.id}"
- end
-
- def root
- "#{Rails.root}/public"
- end
-
- def cache_dir
- " ./tmp/uploads/#{mounted_as}/"
- end
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- version :thumb, :if => :image? do
- process :resize_to_fill => [300, 200, gravity = 'Center']
- end
-
-
-
-
-
-
-
-
-
-
- protected
-
- def image?(new_file)
- new_file.content_type.start_with? 'image'
- end
- end
|