Class: Fog::Proxmox::MultipartIsoUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/proxmox/compute/models/multipart_iso_upload.rb

Overview

Prepares a streamed multipart ISO upload and its content type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body_params) ⇒ MultipartIsoUpload

Returns a new instance of MultipartIsoUpload.

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/proxmox/compute/models/multipart_iso_upload.rb', line 28

def initialize(body_params)
  filename = body_params.fetch(:filename)
  raise ArgumentError, "Invalid ISO filename: #{filename}" unless filename.match?(/\A[a-zA-Z0-9][a-zA-Z0-9._-]*\.iso\z/i)

  file = body_params.fetch(:file)

  boundary = '-' * 30 + SecureRandom.hex(15)
  prefix = build_multipart_content(boundary, 'content', 'iso')
  prefix << build_multipart_header(boundary, 'filename', filename: filename)
  @body = MultipartBody.new(prefix, file, build_multipart_closing(boundary))

  @content_type = "multipart/form-data; boundary=#{boundary}"
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



26
27
28
# File 'lib/fog/proxmox/compute/models/multipart_iso_upload.rb', line 26

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



26
27
28
# File 'lib/fog/proxmox/compute/models/multipart_iso_upload.rb', line 26

def content_type
  @content_type
end