Created
April 25, 2011 21:02
-
-
Save cookrn/941212 to your computer and use it in GitHub Desktop.
Simple Mount Classes With CarrierWave
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 Image | |
extend CarrierWave::Mount | |
mount_uploader :image , ImageUploader | |
end |
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 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 |
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 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