Created
March 10, 2011 03:03
-
-
Save mtmcfarl/863508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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