Created
May 4, 2012 08:28
-
-
Save nakajijapan/2593294 to your computer and use it in GitHub Desktop.
test program for rest connection
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'rest_client' | |
url = "http://localhost:5000/upload_file" | |
filename = File.expand_path('./test.jpg', File.dirname(__FILE__)) | |
f = File.new(filename, "rb") | |
begin | |
response = RestClient.post( | |
url, | |
"photo[upload_file]" => f, | |
"user_id" => "1", | |
) | |
rescue => expand_path | |
p "error ---------------" | |
p e.responseelse | |
p response.code | |
p response.headers | |
p response.to_str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment