Class: Net::HTTP::MultipartPost

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http_multipart_post.rb

Constant Summary collapse

BOUNDARY =
"MichaelNiessnerIsSuperDuperAwesome"

Instance Method Summary collapse

Constructor Details

#initialize(url, params) ⇒ MultipartPost

Returns a new instance of MultipartPost.



24
25
26
27
28
# File 'lib/net/http_multipart_post.rb', line 24

def initialize(url, params)
  @url = url
  @multipart_post_files = extract_file_parameters_from(params)
  @params = extract_non_file_parameters_from(params)
end

Instance Method Details

#postObject



30
31
32
33
34
35
36
37
38
# File 'lib/net/http_multipart_post.rb', line 30

def post
  req = Post.new(url.path)
  req.body = body
  req.content_type = content_type
  req.basic_auth url.user, url.password if url.user
  Net::HTTP.new(url.host, url.port).start {|http|
    http.request(req)
  }    
end