Last Updated: February 25, 2016
·
2.422K
· rshetty

MultiPart Form POST with curb

require 'curb'

c = Curl::Easy.new("http://localhost:3000/api/companies")
c.multipart_form_post = true


c.http_post(Curl::PostField.content('company[name]', "rajeev"),
        Curl::PostField.content('company[rep_name]', "Awesome"),
        Curl::PostField.content('company[rep_designation]', "daa"),
        Curl::PostField.content('company[rep_image]', "my_id"),
        Curl::PostField.content('company[company_large_logo]', "d"),
        Curl::PostField.content('company[company_small_logo]', "sds"),
        Curl::PostField.content('company[company_social_contacts]', "my_id"),
        Curl::PostField.content('company[company_writeup]', "my_id"),
        Curl::PostField.content('company[website]', "Some"),
        Curl::PostField.content('company[active]', "1"),
        Curl::PostField.file('logo_attributes', "spec/support/dogs.png"))

puts c.body_str