Class: OauthChina::Multipart::FileParam

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth_china/multipart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(k, filename, content) ⇒ FileParam

Returns a new instance of FileParam.



21
22
23
24
25
# File 'lib/oauth_china/multipart.rb', line 21

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

Instance Attribute Details

#contentObject

Returns the value of attribute content.



20
21
22
# File 'lib/oauth_china/multipart.rb', line 20

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



20
21
22
# File 'lib/oauth_china/multipart.rb', line 20

def filename
  @filename
end

#kObject

Returns the value of attribute k.



20
21
22
# File 'lib/oauth_china/multipart.rb', line 20

def k
  @k
end

Instance Method Details

#to_multipartObject



27
28
29
30
31
# File 'lib/oauth_china/multipart.rb', line 27

def to_multipart
  #return "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"; filename=\"#{filename}\"\r\n" + "Content-Transfer-Encoding: binary\r\n" + "Content-Type: #{MIME::Types.type_for(@filename)}\r\n\r\n" + content + "\r\n "
  # Don't escape mine
  return "Content-Disposition: form-data; name=\"#{k}\"; filename=\"#{filename}\"\r\n" + "Content-Transfer-Encoding: binary\r\n" + "Content-Type: #{MIME::Types.type_for(@filename)}\r\n\r\n" + content + "\r\n"
end