Sha256: 7bcd8177acf04169f4d61dcec9c02eeb2e99c9a7877d0193737b6f5b5432c161

Contents?: true

Size: 1.01 KB

Versions: 76

Compression:

Stored size: 1.01 KB

Contents

module Fog
  module Compute
    class Ecloud
      module Shared

        def validate_upload_file_options(options)
          required_opts = [:file, :path, :credentials]
          unless required_opts.all? { |opt| options.has_key?(opt) }
            raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
          end
        end

      end

      class Real

        def virtual_machine_upload_file(vm_uri, options)
          validate_upload_file_options(options)
          request(
            :expects => 204,
            :method => 'POST',
            :headers => {'Content-Type' => 'application/octet-stream', 'X-Guest-User' => options[:credentials][:user], 'X-Guest-Password' => options[:credentials][:password], 'Content-Range' => "0-#{options[:file].bytesize - 1}/#{options[:file].bytesize}"},
            :body => options[:file],
            :uri => vm_uri + "?path=#{options[:path]}",
            :parse => true
          )
        end
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 11 rubygems

Version Path
fog-1.22.0 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-1.21.0 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-1.20.0 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-1.19.0 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb