Skip to content

Instantly share code, notes, and snippets.

@michaelkoper
Last active August 29, 2015 14:03
Show Gist options
  • Save michaelkoper/debc900aa0c6779e896b to your computer and use it in GitHub Desktop.
Save michaelkoper/debc900aa0c6779e896b to your computer and use it in GitHub Desktop.
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