Skip to content

Instantly share code, notes, and snippets.

@cookrn
Created April 25, 2011 21:02
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 cookrn/941212 to your computer and use it in GitHub Desktop.
Save cookrn/941212 to your computer and use it in GitHub Desktop.
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