如何使用Net :: HTTP(Rails)发送完整的POST请求

时间:2013-04-08 11:14:54

标签: ruby-on-rails ruby

我想发送一个完整的请求:

POST /2012-09-25/jobs HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: */*
Host: elastictranscoder.amazonaws.com:443
x-amz-date: Mon, 14 Jan 2013 17:49:52 GMT
Authorization: AWS4-HMAC-SHA256 
           Credential=AccessKeyID/request-date/Elastic Transcoder endpoint/ets/aws4_request,
           SignedHeaders=host;x-amz-date;x-amz-target,
           Signature=calculated-signature
Content-Length: number of characters in the JSON string
{
"Input":{
  "Key":"AAAA",
  "FrameRate":"auto",
  "Resolution":"auto",
  "AspectRatio":"auto",
  "Interlaced":"auto",
  "Container":"auto"
},
"Output":{
  "Key":"BBBB",
  "ThumbnailPattern":"pattern",
  "Rotate":"auto",
  "PresetId":"12345"
},
"PipelineId":"987654"
}

如何在Rails中使用Net::HTTP进行创建?

1 个答案:

答案 0 :(得分:3)

查看这些,POST表单请求,文件上传 - 输入类型=“文件”样式

http://www.rubyinside.com/nethttp-cheat-sheet-2940.html

https://github.com/augustl/net-http-cheat-sheet