ruby multipart post image with digest auth

1aaf6o9v  于 2024-01-07  发布在  Ruby
关注(0)|答案(1)|浏览(148)

Given I have this,using Ruby 1.9.3p194
身份验证为身份验证

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

字符串
我得到错误
我试过Typheous,赞助人,机械化, curl ,但想找到一种方法,是简单的,例如工程.

curl --digest -u myusrname:password  -F "[email protected]" "https://api.somewhere.com/upload"


Curl什么也不发布,也不像预期的那样工作。我已经得到保证,API接受帖子,我有一个简单的网页,通过一个简单的表单做我需要做的事情,它工作得很好
有谁知道前面最容易的路是什么?

ybzsozfc

ybzsozfc1#

解决了这个问题,回到了Curb。这是一个REST风格的API,RestClient对摘要做了一些奇怪的事情。HttpClient也发布了空白文件。Curb做到了。

相关问题