Skip to content

Instantly share code, notes, and snippets.

@cookrn

cookrn/image.rb

Created Apr 25, 2011
Embed
What would you like to do?
Simple Mount Classes With CarrierWave
class Image
extend CarrierWave::Mount
mount_uploader :image , ImageUploader
end
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :fog
# Limit possible extensions
def extension_white_list
%w(jpg jpeg gif png)
end
# Set the storage directory
def store_dir
"images"
end
# Versions
version :thumb do
process :resize_to_fill => [200,132]
end
end
class App < Sinatra::Base
post "/upload/image" do
# Example Image Handling Code
img = Image.new
img.image = params["file"]
img.image.store! # => will save to S3!
# do some other stuff....
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment