1
我試圖做到以下幾點,但是Web服務不是REST,並且不需要多個部分。我要怎麼做才能發佈圖片?我可以使用rest-client將一個二進制文件發送到沒有multipart的HTTP嗎?
@response = RestClient.post('http://www.postful.com/service/upload',
{:upload => {
:file => File.new("#{@postalcard.postalimage.path}",'rb')
}
},
{"Content-Type" => @postalcard.postalimage.content_type,
"Content-Length" => @postalcard.postalimage.size,
"Authorization" => 'Basic xxxxxx'
} # end headers
) #close arguments to Restclient.post