Created
October 17, 2012 18:47
-
-
Save ssuda/3907327 to your computer and use it in GitHub Desktop.
zipplease sample in Ruby on Rails
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
=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