Skip to content

Instantly share code, notes, and snippets.

@igaln
Created April 19, 2011 16:37
Show Gist options
  • Save igaln/928727 to your computer and use it in GitHub Desktop.
Save igaln/928727 to your computer and use it in GitHub Desktop.
saving a bitmap shot from Flash AS3 with RMagick to Sinatra to Heroku to Amazon s3
post "/newtest/:filename/:title" do
image = Magick::Image.from_blob(request.body.read).first
puts image.inspect
@title = params[:title]
@filename = params[:filename]
n = VideoThread.new
n.title = @title
n.created_at = Time.now
n.updated_at = Time.now
n.save
n.colors.create :filename => @filename, :hex_value => "FDD017", :width => 130, :height => 109
AWS::S3::Base.establish_connection!(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
AWS::S3::S3Object.store("#{@filename}.jpg", image.resize(130, 110).to_blob, "theoryclub", :access => :public_read)
redirect '/'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment