Class: Videojuicer::OAuth::Multipart::FileParam

Inherits:
Object
  • Object
show all
Defined in:
lib/videojuicer/oauth/multipart_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, filename, content) ⇒ FileParam

Parameters

key<~to_s>

The parameter key.

filename<~to_s>

Name of the file for this parameter.

content<~to_s>

Content of the file for this parameter.



37
38
39
40
41
# File 'lib/videojuicer/oauth/multipart_helper.rb', line 37

def initialize(key, filename, content)
  @key      = key
  @filename = filename
  @content  = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



31
32
33
# File 'lib/videojuicer/oauth/multipart_helper.rb', line 31

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



31
32
33
# File 'lib/videojuicer/oauth/multipart_helper.rb', line 31

def filename
  @filename
end

#keyObject

Returns the value of attribute key.



31
32
33
# File 'lib/videojuicer/oauth/multipart_helper.rb', line 31

def key
  @key
end

Instance Method Details

#to_multipartObject

Returns

String

The file parameter in a form suitable for a multipart request.



46
47
48
# File 'lib/videojuicer/oauth/multipart_helper.rb', line 46

def to_multipart
  return %(Content-Disposition: form-data; name="#{key}"; filename="#{filename}"\r\n) + "Content-Type: #{MIME::Types.type_for(@filename).first}\r\n\r\n" + content + "\r\n"
end