0

Given I have this, using Ruby 1.9.3p194

Authentication is digestauth

require 'json'
require 'httpclient'

API_URL= "https://api.somewhere.com/upload"
API_KEY='blahblah'
API_SECRET ='blahlbah'
IMAGE ='someimage.png'

h=HTTPClient.new
h.set_auth(API_URL, API_KEY, API_SECRET)

File.open(IMAGE) do |file|
  body = { 'image' => file}
  res = h.post(API_URL, body)
  p res.inspect
end

I get errors

Ive tried Typheous, Patron, Mechanize, Curl but want to find a way that is simple and works e.g.

curl --digest -u myusrname:password  -F "image=@image.png" "https://api.somewhere.com/upload"

Curl posts nothing and doesnt work as expected. Ive been assured that the API accepts posts, I have a simple web page that does what I need to do via a simple form and it works fine

Any one know what the easiest way ahead is?

Thanks

4

1 回答 1

0

解决它,回到路边。它是一个 RESTful API,RestClient 对摘要做了一些时髦的事情。HttpClient 也发布了空白文件。路边做到了。

于 2012-09-03T15:33:57.973 回答