Ruby rest-client file upload as multipart form data with basic authenticaion

后端 未结 4 1883
不思量自难忘°
不思量自难忘° 2021-02-05 22:02

I understand how to make an http request using basic authentication with Ruby\'s rest-client

response = RestClient::Request.new(:method => :get, :url => @b         


        
4条回答
  •  猫巷女王i
    2021-02-05 22:28

    How about using a RestClient::Payload with RestClient::Request... For an example:

    request = RestClient::Request.new(
              :method => :post,
              :url => '/data',
              :user => @sid,
              :password => @token,
              :payload => {
                :multipart => true,
                :file => File.new("/path/to/image.jpg", 'rb')
              })      
    response = request.execute
    

提交回复
热议问题