当前位置 博文首页 > ruby使用restclient上传服务器本地文件示例

    ruby使用restclient上传服务器本地文件示例

    作者:admin 时间:2021-02-07 12:20

    使用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 #返回结果

    js
下一篇:没有了