Skip to content

Instantly share code, notes, and snippets.

@ssuda

ssuda/zipplease.rb

Created Oct 17, 2012
Embed
What would you like to do?
zipplease sample in Ruby on Rails
=begin
#routes.rb
post "demo/flicker"
#Gemfile
gem 'uuid'
gem 'rest-client'
#Sample request
curl -X POST -H 'Content-Type:application/json' -d '["http://sample.org/1", "http://sample.org/2"]' -H 'Accept:application/json' http://localhost:3000/demo/flicker
=end
class DemoController < ApplicationController
respond_to :json
@@uuid = UUID.new
def flicker
images = params['_json']
# Create the JSON payload to send to ZipPlease
zipRequest = {
:accountKey => "6B5qClA0SG2er7x7PmZTK4QU", # Not real.
:accountSecret => "jHxRb2y3CevJyROL96hYKcE0oAI", # Get your own.
:zipName => "zipPleaseFlickrDemo_" + @@uuid.generate + ".zip",
:files => images,
:compress => false # already jpegs
}
response = RestClient.post 'http://www.zipplease.com/api/zips', zipRequest.to_json, :content_type => :json, :accept => :json
render :json => response
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.