我无法使用 RestClient 将此 CURL 请求转换为 Ruby:
system("curl --digest -u #{@user}:#{@pass} '#{@endpoint}/#{id}' --form image_file=@'#{path}' -X PUT")
我不断收到400 Bad Request
错误。据我所知,请求确实得到了正确的身份验证,但从文件上传部分挂断了。这是我最好的尝试,所有这些都让我遇到了 400 个错误:
resource = RestClient::Resource.new "#{@endpoint}/#{id}", @user, @pass
#attempt 1
resource.put :image_file => File.new(path, 'rb'), :content_type => 'image/jpg'
#attempt 2
resource.put File.read(path), :content_type => 'image/jpg'
#attempt 3
resource.put File.open(path) {|f| f.read}, :content_type => 'image/jpg'