Last active
August 29, 2015 14:03
-
-
Save michaelkoper/debc900aa0c6779e896b to your computer and use it in GitHub Desktop.
This file contains 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
class CarrierStringIO < StringIO | |
def original_filename | |
# the real name does not matter | |
"photo.jpeg" | |
end | |
def content_type | |
"image/jpeg" | |
end | |
end | |
class Account < ActiveRecord::Base | |
mount_uploader :logo, LogoUploader | |
def logo_data=(data) | |
io = CarrierStringIO.new(Base64.decode64(data)) | |
self.logo = io | |
end | |
end | |
class LogoUploader < CarrierWave::Uploader::Base | |
include Cloudinary::CarrierWave | |
process :convert => 'png' | |
process :tags => ['logo'] | |
version :standard do | |
cloudinary_transformation :transformation => [{:width => 140 , :height => 140, :crop => :limit}] | |
end | |
version :thumbnail do | |
cloudinary_transformation :transformation => [{:width => 70, :height => 70, :crop => :limit}] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment