Hi, I''m interested in using Mechanize as a way around manual multipart form creation. But the API is really centered around the idea of a form built from a page. I''d love to see a syntax like: response = agent.post(''http://www.mydomain.com/upload'', :image => File.new(file), :title => "My image", :description => "an image description") Basically Mechanize#post would just automagically switch when it saw a File object for a post value. I''m actually doing this for flickr uploading, but none of the ruby libraries I''ve tried so far actually support uploading without headaches. Has work been done on this front? Am I totally off-base? If the answer to both of these is no, perhaps I''ll check out the latest mechanize and see if I can work up a patch. Oh also, I know I could use curb for this, but I really like mechanize and also curb isn''t jruby compatible. Thanks, Mat
Aaron Patterson
2008-Mar-10 19:09 UTC
[Mechanize-users] Mechanize for multi-part form post
On Sun, Mar 09, 2008 at 08:46:44PM -0400, Mat Schaffer wrote:> Hi, > > I''m interested in using Mechanize as a way around manual multipart > form creation. But the API is really centered around the idea of a > form built from a page. I''d love to see a syntax like: > > response = agent.post(''http://www.mydomain.com/upload'', > :image => File.new(file), > :title => "My image", > :description => "an image description") > > Basically Mechanize#post would just automagically switch when it saw a > File object for a post value. I''m actually doing this for flickr > uploading, but none of the ruby libraries I''ve tried so far actually > support uploading without headaches.Yes, I like this syntax.> > Has work been done on this front? Am I totally off-base? If the > answer to both of these is no, perhaps I''ll check out the latest > mechanize and see if I can work up a patch.WWW::Mechanize already has a post method, I''d just have to add the logic to auto-detect the IO object and have it automagically post correctly. I like this feature, so I''ll work on adding it. :-) -- Aaron Patterson http://tenderlovemaking.com/
On Mar 10, 2008, at 3:09 PM, Aaron Patterson wrote:>> Has work been done on this front? Am I totally off-base? If the >> answer to both of these is no, perhaps I''ll check out the latest >> mechanize and see if I can work up a patch. > > WWW::Mechanize already has a post method, I''d just have to add the > logic > to auto-detect the IO object and have it automagically post correctly. > > I like this feature, so I''ll work on adding it. :-)Sweet! I was planning on doing some work on my uploading this evening, so I''l keep you posted if I come up with any interesting developments. Pleasure talking to you as always, Aaron! -Mat