Class: OneviewSDK::FirmwareBundle
- Inherits:
-
Object
- Object
- OneviewSDK::FirmwareBundle
- Defined in:
- lib/oneview-sdk/resource/firmware_bundle.rb
Overview
Firmware bundle resource implementation
Constant Summary collapse
- BASE_URI =
'/rest/firmware-bundles'.freeze
- BOUNDARY =
'---OneView-SDK-RubyFormBoundaryWzS4H31b7UMbKMCx'.freeze
Class Method Summary collapse
-
.upload(client, file_path) ⇒ OneviewSDK::FirmwareDriver
Upload a firmware bundle file.
Class Method Details
.upload(client, file_path) ⇒ OneviewSDK::FirmwareDriver
Upload a firmware bundle file
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/oneview-sdk/resource/firmware_bundle.rb', line 11 def self.upload(client, file_path) fail "ERROR: File '#{file_path}' not found!" unless File.file?(file_path) type = case File.extname(file_path) when '.zip' then 'application/x-zip-compressed' when '.exe' then 'application/x-msdownload' else 'application/octet-stream' end body = "--#{BOUNDARY}\r\n" body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file_path)}\"\r\n" body << "Content-Type: #{type}\r\n\r\n" body << File.read(file_path) body << "\r\n--#{BOUNDARY}--" = { 'Content-Type' => "multipart/form-data; boundary=#{BOUNDARY}", 'uploadfilename' => File.basename(file_path), 'body' => body } response = client.rest_post(BASE_URI, ) data = client.response_handler(response) OneviewSDK::FirmwareDriver.new(client, data) end |