ruby http请求组件

github地址
https://github.com/rest-client/rest-client

gemfile里添加

gem 'rest-client', '~> 2.0'

执行
bundle install

代码里

# 要请求接口地址
# 上传文件的key名字
# file 文件的绝对路径
 resp = RestClient.post url, :file => File.new(file, 'rb')
 json = JSON.parse(resp)
posted @ 2021-05-16 14:56  HaimaBlog  阅读(72)  评论(0编辑  收藏  举报