Class: VCloudSdk::Connection::FileUploader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_vcloud_sdk/connection/file_uploader.rb

Class Method Summary collapse

Class Method Details

.upload(href, file, vcloud_auth_header, http_method = :Put) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ruby_vcloud_sdk/connection/file_uploader.rb', line 6

def upload(href, file, vcloud_auth_header, http_method = :Put)
  request = create_request(href, file, vcloud_auth_header, http_method)
  net = create_connection(href)
  net.start do |http|
    response = http.request(request) {
      |http_response| http_response.read_body }
    raise ApiRequestError "Error Response: #{response.code}" if
      response.code.to_i >= 400
    response
  end
end