站长资源脚本专栏
ruby使用restclient上传服务器本地文件示例
简介使用RestClient上传服务器本地文件复制代码 代码如下:url = 'http://xx' #post到urlfield_hash = {key: key, token: token} #post数据request = RestClient.post url, field_hash.mer
使用RestClient上传服务器本地文件
复制代码 代码如下:
url = 'http://xx' #post到url
field_hash = {key: key, token: token} #post数据
request = RestClient.post url, field_hash.merge(file: File.new(File.join('public', "#{params[:logo]}"), 'rb')) #上传文件
reponse = request.to_s #返回结果
下一篇:你应该知道的Ruby代码风格