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

后端 未结 4 1911
不思量自难忘°
不思量自难忘° 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条回答
  •  天命终不由人
    2021-02-05 22:20

    RestClient API seems to have changed. Here's the latest way to upload a file using basic auth:

    response = RestClient::Request.execute(
      method: :post,
      url: url,
      user: 'username',
      password: 'password',
      timeout: 600, # Optional
      payload: {
        multipart: true,
        file: File.new('/path/to/file, 'rb')
      }
    )
    

提交回复
热议问题