Skip to content

Instantly share code, notes, and snippets.

@mtmcfarl
Created March 10, 2011 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtmcfarl/863508 to your computer and use it in GitHub Desktop.
Save mtmcfarl/863508 to your computer and use it in GitHub Desktop.
# encoding: utf-8
class AssetUploader < CarrierWave::Uploader::Base
cattr_accessor :current_account
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
#storage :file
storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
# files will be stored scoped to the currently logged in domain
"#{self.current_account.domain}/#{model.id}"
end
version :thumb do
process :resize_to_limit => [100, 100] if :image?
end
def image?
# access the to be uploaded file and detect if its an image or not
# something like !asset.content_type.match(/image|png|jpg|jpeg|gif/).nil?
end
# def extension_white_list
# %w(jpg jpeg gif png)
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment