Hi, I''m in need to send a file throught an http post and examine the response within a Rails project. Net::HTTP is powerful but way too hard to use, I''m in need of something slick and quick to use and manage. Actually I''ve found Curb, which works like a charm ( http://rubyforge.org/projects/curb ) but it has a big problem: it depends on external libraries (curlib) and doesn''t work at all on win (which is the platform used by most of our team). What would really be a great tool is an high level libraries which relies on Net::HTTP o similar, which allows me to achieve my results with really compact statements. Curb is really smart at this: c = Curl::Easy.new post_url c.multipart_form_post = true c.http_post( Curl::PostField.content(''some_var_name'', some_var_value), Curl::PostField.file(''file_name'', incomming_file.path) ) puts c.body_str if c.response_code == 200 Is there any other similar library that can work on multiple platforms -- Ashkey < Jules Piccotti --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Jules, Ashkey wrote:> Hi, I''m in need to send a file throught an http post > and examine the response within a Rails project. > Net::HTTP is powerful but way too hard to use, > I''m in need of something slick and quick to use and > manage.I''m not sure I understand you completely. What is it that the send_file or send_data methods (api.rubyonrails.org) don''t do that you need? Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 12, 2007, at 10:38 AM, Ashkey wrote:> Hi, I''m in need to send a file throught an http post and examine the > response within a Rails project. > Net::HTTP is powerful but way too hard to use, I''m in need of > something slick and quick to use and manage. > > Actually I''ve found Curb, which works like a charm ( > http://rubyforge.org/projects/curb ) but it has a big problem: it > depends on external libraries (curlib) and doesn''t work at all on win > (which is the platform used by most of our team). > > What would really be a great tool is an high level libraries which > relies on Net::HTTP o similar, which allows me to achieve my results > with really compact statements. > > Curb is really smart at this: > > c = Curl::Easy.new post_url > c.multipart_form_post = true > c.http_post( > Curl::PostField.content(''some_var_name'', some_var_value), > Curl::PostField.file(''file_name'', incomming_file.path) > ) > puts c.body_str if c.response_code == 200That doesn''t look much easier than Net::HTTP. my_form_data = {:title => ''Example'', :body => ''Content''} res = Net::HTTP.post_form( URI.parse(''http://www.example.com/recipient/''), my_form_data) puts res.response.body if res.response.code == 200 What is it about Curl that you prefer? James. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---