Skip to content

Instantly share code, notes, and snippets.

@nakajijapan
Created May 4, 2012 08:28
Show Gist options
  • Save nakajijapan/2593294 to your computer and use it in GitHub Desktop.
Save nakajijapan/2593294 to your computer and use it in GitHub Desktop.
test program for rest connection
#!/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